Force ordering when a migration script runs
Phillip_Smith
Posts: 1 New member
I have just started using SQL Source Control.
I want to seed some base tables with some initial data that should be shipped with the database.
These tables are not look-up tables and are not candidates for linked tables.
They are entity tables such as User, Role and Organization. There is circular referencing between some of them.
The entity tables also depend on the lookup data being there.
I wrote a data migration script that:
1. Turns off all relevant table constraints
2. Seeds the data
3. Turns on the constraints
I checked the migration script in last.
However, it seems to run before linked data is inserted.
Is this the case?
Can I force my migration script to be the last thing run?
Best regards
Phil
I want to seed some base tables with some initial data that should be shipped with the database.
These tables are not look-up tables and are not candidates for linked tables.
They are entity tables such as User, Role and Organization. There is circular referencing between some of them.
The entity tables also depend on the lookup data being there.
I wrote a data migration script that:
1. Turns off all relevant table constraints
2. Seeds the data
3. Turns on the constraints
I checked the migration script in last.
However, it seems to run before linked data is inserted.
Is this the case?
Can I force my migration script to be the last thing run?
Best regards
Phil
Tagged:
Answers
No, migration scripts always run at the start of the deployment script and for that reason can't depend on static data.
https://documentation.red-gate.com/soc6/common-tasks/working-with-migration-scripts/static-data-and-migrations
Thank you,
Product Support Engineer
Redgate Software Ltd
Please see our Help Center for detailed guides on how to use our tools