Migration script causing issues...?
robinw
Posts: 17 New member
Hi
I have attempted to use a migration script on my local database to do the following:
- add a column to an existing table
- populate new column with a default value of zero
- alter new column to be not null
By all the accounts the migration script works as designed - however I have come across an issue...
Another user has freshly created the same database and done his first "Get Latest". He noticed that not all roles, schemas and permissions were pulled down from Source Control (Git).
Having checked source control, it seems that the permissions are indeed there - so they should have been pulled down to his SSMS.
He then checked his Commit tab and it was suggesting that these objects freshly pulled down (without the relevant objects), should be committed to source control - which is wrong.
I have come across one correlation: the table the migration script affects needs to have associated objects pulled across as well (dependencies) before a "Get Latest" is achieved. Unfortunately, when a Get Latest is done, certain role permissions and a schema from these dependencies are missing - and the objects affected with things missing are the objects associated with the migration script object.
Steps to reproduce the issue:
- Run code similar to the following on local database:
ALTER TABLE MetaData.Table1
ADD Column1 BIT NULL
GO
UPDATE MetaData.Table1
SET Column1 = 0
GO
ALTER TABLE MetaData.Table1
ALTER COLUMN Column1 BIT NOT NULL
GO
ADD Column1 BIT NULL
GO
UPDATE MetaData.Table1
SET Column1 = 0
GO
ALTER TABLE MetaData.Table1
ALTER COLUMN Column1 BIT NOT NULL
GO
- Click on the Migrations tab in Source Control
- Click Generate script
- Replace all code generated with the code above
- Click on commit tab and commit the changes via migration script. Push to Git. Change works successfully
- Another user creates a fresh copy of database on another machine. Links to source control and clicks Get Latest
- All objects appear to be pulled form SC but Commit tab says otherwise
- Code lines missing are mostly permissions to objects via database roles - ie GRANT INSERT ON TABLE TO DBROLE
- MetaData schema also has GRANT SELECT ON SCHEMA permission missing
Any questions, please let me know.
Tagged:
Answers
Thanks for posting. I wasn't able to reproduce it with 7.0.25. Please upgrade and let us know if it make any difference.
If problem persists, would you be able to share your git repository with us? I've raised a ticket and I'll get in touch with you by email shortly.
Tianjiao Li | Redgate Software
Have you visited our Help Center?