0

I need to specify the path to the file with migrations script in Execute Sql Script step. This step run on Octopus Server, and file is inside the package.

I have a dotnet ef migrations script -i ... as a build step.
Produced sql file is copied to the directory where application is published to.
This directory is then pushed to Octopus package feed.

Documentation shows how to access package contents in pre- or post-deploy scripts, but that is probably not what I need because applying migrations is a separate step in deployment process.

1 Answer 1

1

You could read the contents of the script into an output variable in a pre/post deployment script in the deployment step and then use that variable value as the script body in the SQL - Execute Script step.

Since this is a community step there is no way currently to specify that the script source is from a package.

Sign up to request clarification or add additional context in comments.

5 Comments

I keep asking myself whether I just complicate things, or dev world is somehow intrinsically flawed. It seems to be self evident flow: put application instances offline, apply migrations, deploy new version of application, bring instances online. I would expect frameworks and tools be designed for as smooth experience as possible. However, dotnet ef cannot be run against published application out of the box, Octopus does not allow to easily access package contents to run scripts or binaries.
I'd rather keep as an artifact.
@PavelVoronin you can run a script from a package using the built-in script steps. Also, since 2018.8.0, you can reference a package from a script step, such as your application package, which would allow you to get access to the script file and application binaries to be able to run your migration there. This won't give you the tools to execute the Sql script, but you could package the tools up and add the tool package as an additional package reference on the step. Each package reference will be unpacked to a subdirectory of the same name as the package.
@AlexM you can't access the contents of an artifact in a later step, so I don't think an artifact is going to help in this scenario
how about passing the artifact created in a previous step into, for example, sqlcmd utility?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.