diia-open-source / be-auth-service

European Union Public License 1.2
70 stars 7 forks source link

DB migration: missed revert `down` operations #8

Open kosiakMD opened 6 months ago

kosiakMD commented 6 months ago

Hi "Dia" Team,

I see multiple migrations that have only up forward logic but no revert down.

It's not critical (at least for now), but it could be a very variably risky issue if you follow this approach further.

Regards,

Anton

num8er commented 6 months ago

I doubt down is necessary.

Use case:

  1. added field
  2. during app work that field was filled by user
  3. revert deletes that field - we are losing that data

IMO better to keep data and do revert by hand if there is a need

Also I see that they are using mongodb which means database engine does not have strict schema. So based on that fact only up is good for keeping change history. Think about in one version we added to all docs some field - since it's schemaless db so down will not revert that field, better to have _remove_such_field_from_some_collection migration which shows that document shape was modified time to time (it's better to keep history of document modification).