generalpiston / typeorm-encrypted

Encrypted field for typeorm.
MIT License
74 stars 19 forks source link

Describe data migration in README #20

Closed generalpiston closed 3 years ago

generalpiston commented 4 years ago

When adding the transformer to an existing table, a data migration is needed. See https://github.com/generalpiston/typeorm-encrypted/issues/19#issuecomment-650979933 for more detail.

Destreyf commented 4 years ago

Just wanted to give my 2 cents, I think the method you described in #19 is a good way to handle it, but i was thinking through a couple other things, it may be possible to determine if the field is already encrypted, and have an argument passed into the transformer configuration like "migrateToEncrypted" and possibly add a reverse method, of "migrateFromEncrypted" so that you could have switches to migrate stored data to-from an encrypted state upon access/save.

I believe this would need to be an opt-in mechanic as to not possibly corrupt any data, but this would provide users with an easy way to push a release with the migrate existing data flag turned on, and then in the next version, after they've gotten all their data moved, turn the flag back off for existing data.

I do think this deserves more discussion to determine if it's the correct way to handle it, or if it's even necessary.

rubiin commented 4 years ago

@Destreyf that looks good. It would make the work of migration less hassle