How to create DacPac from script files to automate DB deployment?

3.8k views Asked by At

I need to automate SQL Server DB deployment using Azure DevOps. I don't want to give any alter statement. I will have a folder structure with tables, stored procedures, views & functions in repository. Every folder will contain only create scripts. Is there anyway to create DacPac file with that folder structure or any other way, other than DacPac deployment using that folder structure?

Note: I don't want to create DB project using Visual Studio. And I don't want to create a DacPac file directly from SQL Server Management Studio and checkin the same to source control. And I am not in a situation to pay for license.

3

There are 3 answers

0
Shamrai Aleksander On

You can try to use SQL Database Projects extension in Azure Data Sudio. It supports VS SQL Database Project and it supports builds from the command line: Build a database project from command line

0
Panagiotis Kanavos On

What you describe is the database project. A dacpac is the build output of a Database project. There are no licenses involved. All the tools that produce dacpac files are free:

0
Vijayakumar Udupa On

Not exactly about sql server or dacpac, but more generic solution applicable to this use case.

Please take a look at liquibase and flyway projects. Both can help to keep track of what’s already deployed to database and deploy any new items automatically as part of CICD pipeline. Flyway could be better solution to your question, mostly you need to add some prefix to existing file names defining order of deployment, flyway can manage rest of the tasks for you. Liquibase has its own advantages, but adopting it at this stage needs some changes across all scripts.

Both projects have info on how to include this step in your CICD pipeline.