Can't create a migration script based on static data
Bas_K
Posts: 15 Bronze 1
Hi Guys,
I'm trying to create a migration script to run AFTER my static data has been deployed. The migration script contains a select from the static data table that is ran in the same deployment script. Redgate sees the migration script as a model change aswell, which means it's embedded in the same script. Sadly the order of scripts being ran is in my case wrong. The static data should first be inserted, after that the migration script needs to run. Is there any way I can do this?
I saw the article that this does not seem to work: https://documentation.red-gate.com/display/SOC5/Static+data+and+migrations
I'm trying to create a migration script to run AFTER my static data has been deployed. The migration script contains a select from the static data table that is ran in the same deployment script. Redgate sees the migration script as a model change aswell, which means it's embedded in the same script. Sadly the order of scripts being ran is in my case wrong. The static data should first be inserted, after that the migration script needs to run. Is there any way I can do this?
I saw the article that this does not seem to work: https://documentation.red-gate.com/display/SOC5/Static+data+and+migrations
Tagged:
Answers
May I ask what the migration script is doing?
I have the following tables as static data:
dbo.Permission
dbo.Action
My migration script is as followed:
INSERT INTO dbo.RoleAction
( FK_RoleId ,
FK_ActionId ,
FK_PermissionId ,
Enabled
)
VALUES ( 1000 , -- FK_RoleId - int
2028 , -- FK_ActionId - int
3340 , -- FK_PermissionId - int
1 -- Enabled - bit
)
This fails in production because the static data is not yet deployed and the migration script already runs..
Anyway to solve this?
I realize this is a hack, and gets away from automation, but is this something you do often with migration scripts?
Is there any other way to do this? Instead of this "hack"?
I would love to see this "fix" on the roadmap! I got like 3 manual steps now in my deployment process because of this. It really slows down our automation process.
Cheers