RB.
RB.

Reputation: 37192

Using DSC to create a SQL database (i.e. tables, columns, datatypes, etc)

There are DSC resources to install SQL Server, but there do not appear to be any resources to install a database into SQL Server (i.e. create the tables, columns, datatypes, stored procedures, etc.).

Currently I am using a Script resource to run a install_my_database.sql file, but I was looking for a more DSC-way of doing this (a resource that I can say "Ensure this table, ensure these columns, etc").

Is anyone aware of anything that would meet my needs?

Please note that I am aware that I could write my own DSC resources to do this (and that will be a fun side-project in the future), but I'm really looking for an implemented solution - I'm trying to not reinvent the wheel.

Upvotes: 0

Views: 987

Answers (1)

Jeroen Mostert
Jeroen Mostert

Reputation: 28789

You can package the database and deploy it as a DACPAC (or a BACPAC, which is a DACPAC with a punny name that includes data as well). Installing, upgrading and removing installed databases can be done in a structured way with this, as opposed to running ad-hoc scripts.

The PowerShell gallery hosts a DSC resource for this called xDatabase. Disclaimer: I have no personal experience with it.

Upvotes: 1

Related Questions