Insert on migration
Can we insert some data if table is empty while running migration?
3 Replies
Sure, you'll need manually add the queries that you need to run to the migration file
Thanks, can you please guide more on this. Should I write queries into .sql migrations files or in the trypescript schema/config file ?
I would like to say that unless you have a good reason to do this, is generally considered a bad practice
Migrations are supposed to change the structure of your database, not the data inside.
When this type of operations is needed, people would have a separated script to seed the database after the migration is successful