georgemarshall / django-cryptography

Easily encrypt data in Django
https://django-cryptography.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
371 stars 70 forks source link

Remove encryption #22

Open marianobrc opened 5 years ago

marianobrc commented 5 years ago

Hello, We've been using this package in the fields of a model, but we want to remove encryption from some fields now cause we need to do search lookups. I'm wondering which is the best way to do this. Would it be enough just removing encrypt() from model fields and run makemigrations/migrate? I Guess data will remain encrypted into the DB.

I was thinking in writting some custom migrations like this: 1.- Given field_x is encrypted, add another field field_x_text to the model 2.- Read data from field_x to get unencrypted value and write it in field_x_text 3- Remove field_x 4.- Rename field_x_text to field_x

Any advice would be appreciated. Thanks

thismatters commented 5 years ago

Some of the comments in another issue might help you get this migration complete.

You have basically the right workflow written out. Be sure to backup your database before starting :)