In Rails I'm using backfill gem to backfill data. Is there something similar in node.js? Not migration schema, but filling/populating data in existing tables. For example, when introducing new column we might want to populate it based on other column, or pre-commutate it's value. The closes I found is Sequelize seed
However, seeding is to insert new data, this could be also used for changing data. And it would be ideal to have an option to start backfill multiple times if needed (for example if we want to fix corrupt data)
We use Postgres DB by the way
Any recommendations?
Thanks
This sounds like a job for
default, a generated column or a plainupdate. Problem is thatdefaultcannot reference other columns and a generated value cannot be inserted or updated to anything else. I think sequelizedefaultValueis limited to what can be defined as SQLdefault.You can define the column and let it get initialised with
NULLvalues,update()non-selectively to set your starting default, and whenever you need to revert to that, you can add awhereto the update in order to target the right record(s).Model hooks could let you intercept new records (or any activity on them after they were created) and inject your default.