Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to setup a reviewing migration (and rollback) gate for scripts in Azure DevOps? #3515

Open
sturlath opened this issue Oct 25, 2021 · 9 comments
Assignees
Milestone

Comments

@sturlath
Copy link

Maybe this is should not bee asked here but I´m doing it because of the work that seems to be going into management of deployment with things like bundles , Improve experience for managing migrations and Improve experience deploying databases created by Migrations so here goes. If you feel strongly against it just close it and I´ll ask it there.

My question is, how can I gate/review migration and rollback scripts in DevOps?

The out of the box functionality to review SQL changes with using AzureDevOps is lacking a lot. And also how can I automatically create rollback files for "thisMigration" agains "lastMigration"?

I managed to get a "poor mans version" working but I think this is something that is not going to cut it.

And maybe this will not get better and we need to move to something like Octopus Deploy?

Looking forward hearing your input.

@roji
Copy link
Member

roji commented Oct 25, 2021

@sturlath that's an important question and we're definitely interested in any and all aspects of deploying EF Core applications and Devops. But I'm not sure we'll have much to contribute specifically to doing that in AzDo.

You seem to be looking for a workflow review step that is somehow automatically triggered for a build artifact (i.e. the SQL script). I'd even go a step further and fetch the SQL script from the last successful build, trigger the required vaildation only when there's as a difference, and present a diff view between the two for validation. How to achieve that is a very different question though :)

@sturlath
Copy link
Author

Thanks @roji and yes you are correct about what I am looking for. I just haven´t found anything that fits it except this "poor mans" version I hacked together.

I'll find some place to ask this question and link to this issue so you (or anyone else) can benefit from it later.

And thanks for this input. this would be the dream scenario of course

I'd even go a step further and fetch the SQL script from the last successful build, trigger the required validation only when there's as a difference, and present a diff view between the two for validation.

but let's not hold our breath there :-) I´ll settle for just a small improvement from what we seem to have available in AzDo to day.

@roji
Copy link
Member

roji commented Oct 26, 2021

Agreed. We'd definitely be interested in any guidelines/techniques you come across.

@sturlath
Copy link
Author

sturlath commented Oct 26, 2021

I have created this feature request/question (hopefully) for the Azure Devops folks. Lets see what comes out of that.

And sorry but I snuck another question in my first one that was "how can I automatically create rollback files for "thisMigration" agains "lastMigration"?"

I know I can do something like dotnet ef migrations script -from (MigrationYouWant-1) -to MigrationYouWant but for a build scenario I don´t want to change the definition so I need to be able to have a command that never changes but creates a rollback script between the newest migration script and the one applied to the database. Or something like that...

Doesn't this make sense? I at least would like to be able to auto create rollback sql with out doing anything manual and then I would add them to the review process.

@roji
Copy link
Member

roji commented Oct 26, 2021

That sounds similar to dotnet/efcore#21615 (planned for 7.0), though that's about dotnet ef database update rather than script generation. We should also support ~1 for SQL script generation. /cc @bricelam

@ajcvickers
Copy link
Member

Note from triage: moving this to the docs repo to track investigation and documentation in the 7.0 timeframe.

@ajcvickers ajcvickers transferred this issue from dotnet/efcore Oct 27, 2021
@ajcvickers ajcvickers added this to the 7.0.0 milestone Oct 27, 2021
@ErikEJ
Copy link
Contributor

ErikEJ commented Oct 27, 2021

There is an example of doing this in the accepted reply here:
https://stackoverflow.com/questions/61240633/generate-sql-server-schema-change-script-on-azure-devops-pipeline
(for a .dacpac, but the principle is the same)

@sturlath
Copy link
Author

Ah thanks @ErikEJ I didn´t find that. I'll give it a try and let you know how it went... images and all :-)

@sturlath
Copy link
Author

sturlath commented Nov 1, 2021

@ErikEJ I just got to play with this and as far I can figure out its the same as what I did, just in YAML. It uses Powershell (instead of my CMD) to output the content (doesn´t look any better) that what's shown here below.

I watched Abels video at the bottom and thought I could create my own gate but reading this on gates with "a good gate will typically query an external system"...

So I can´t see that I can add any UI to show the content of an artifact. I´m going to ask this question the pipeline repo and see what feedback I get.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants