Search code examples
database-migrationflyway

Is Seeding Data using database migration tools like Flyway a good practice?


We are in the process of setting up Flyway for our project, and we are having second thoughts on whether we want to seed the data using the Flyway migration or manually using the sql console or some bootstrap script.

Our concern is if we add the seeded data in Flyway, that means further amendments of those data would need to be in Flyway as well. And we'd probably need to use "where field = x" or some other conditions which might already be invalid at a certain point in time, since the data can be altered by the application. And that'll be problematic.

In their documentation, I can't see anything that advises against seeding data.

I'm just wondering if seeding data with migration tools like Flyway is a good idea.


Solution

  • The best fit is usually reference data, where the answer is a clear yes. for user-modifiable data, it depends. If this data is needed initially on all environments, then the answer is probably also yes. At the end of the day if a where condition doesn't hold true anymore in a certain environment later, it probably also means that you don't want to overwrite that data anyway. Or you need to assign fixed synthetic and immutable ids to all row, to which you can then always refer later, even in the face of data changes.