I've been looking to find ways to deploy one particular schema (Schema B) from database (Schema A, Schema B, Schema c..) using dacpac and sqlpackage.exe.
I found this similar question but looks like the links on it have been archived. also found out to put this parameter in sqlpackage.exe cmd DropObjectsNotInSource = false but still both schema are getting deployed. can anyone help?
I found out this can be done using this DeploymentContributorFilterer.
Put the AgileSqlClub.SqlPackageFilter.dll file into the same folder as SqlPackage.exe, and add these commmand line parameters to your deployment:
/p:AdditionalDeploymentContributors=AgileSqlClub.DeploymentFilterContributor /p:AdditionalDeploymentContributorArguments="SqlPackageFilter=IgnoreSchema(**SchemaA**)"
Related
Is it possible and what are best practices for generating schema-qualified object names in a Liquibase change log .sql file?
For example, I want the command liquibase generateChangeLog to generate a .sql file where the objects are schema qualified (CREATE TABLE [schema_name].[table_name]...). What I get is something like CREATE TABLE [table_name]... without the schema qualification.
I have tried the schemas and defaultSchema properties and their command-line equivalent w/no success. I have also tried setting the default schema for the liquibase login w/no success.
P.S. - this is for an MSSQL database.
Have you looked into using --includeSchema or --includeCatalog optional arguments with liquibaseGenerateChangeLog command?
Here's the documentation that mentions these optional arguments:
I want to use database project for script deployment in Azure SQL Server, I don't want to import full database. I just want to use database project for delta script. I added a project and included one script file with none as build action that contains create table statement , I am publishing the project, It's completing successfully but create statement is not executing. What is wrong here? Is there any other way to do this?
TLDR: Set your build action to "Post Deployment Script".
Longer:
What happens in SSDT is that all the files that have a build action of "Build" are built into a model of what the database should look like. When the deploy happens that model is compared to the target database and if there are any changes, a change script it generated and then optionally deployed.
If you have any file marked pre or post deployment script then they are either prepended or appended to the change script and will be run as part of the deployment.
If you have any files with a build action of "None" then SSDT ignores them, you could put anything in there, even an ascii picture of a donkey and the project will still build and deploy (obviously your ascii donkey won't get deployed anywhere).
If you just want to use SSDT to do your deployments you can just set the build action to pre or post deploy and it will be included. This is pretty odd though, either don't use SSDT or use SSDT and put the model of your entire database in there.
Personally, I would use SSDT properly and live the dream.
Ed
I have a VS2015 database project (sqlproj) and I created a lot of test data. I added a parameter to the PostDeploymentScript.sql file and when I need an empty database, I set it false and when I publish it doesn't include test data. When I need a demo database I set it true and when I publish, it also adds test data after deployment.
On the other hand, I want to create two different DACPAC files to prevent manual process and build both of them automatically at once. I searched a little bit and found several articles like this:
http://www.techrepublic.com/blog/data-center/auto-deploy-and-version-your-sql-server-database-with-ssdt/
but I couldn't apply what he said. What am I missing?
I created an (almost) empty database project (Lets say Base.sqlproj) which adds lookup table data after deployment. I created another DB project (Base_Plus_TestData.sqlproj) and added a database reference for the first database.
What I need is, if client needs to deploy empty database I'd like to give them the Base.DACPAC. If client needs to deploy a demo database with test data, I want to give them Base_Plus_TestData.DACPAC.
What should I do for this purpose and what am I doing wrong?
There a couple of extra options over what you already do with a switch to include data, I would choose the first :)
1 - Just give customers who want demo data a script to run after deploying the database (you could do something like use a powershell script/.net app to deploy your data and optionally the data)
2 - The post deploy script can be edited in a dacpac, you could build your project, copy the dacpac and then edit the post deploy script to include your data on one of the dacpacs.
3 - Create a separate ssdt project that references your main database project with a "same database" reference and the extra post deploy script - wheb you build you will get two dacpacs you can deploy either together if you want data or just the database.
If you also have data in your original dacpac to deploy you will need to copy it into the "with data" dacpac.
Ed
Following is the exact scenario in my database project, where I am creating dacpac to deploy databases on target SQL instance:
the database project is having a reference of CLR assembly.
TFS build server is used to build the project
dacpac is getting created during TFS build process
– when i try to run sqlpackage.exe to deploy the dacpac (generated in TFS build process) in my environment, I get an error saying –
*** No file was supplied for reference XXXX.XXXX.XXXX.dll; deployment might fail. When C:\Temp\Dacpac_testing\XXX.XXXXX.XXXX.dacpac was
created, the original referenced file was located
C:\BUILDS\1\XXXX\XXXX\SRC\XXXXXXXX\ASSEMBLIES\XXXX.XXXX.XXXX.dll
How can I create a dacpac to reference the path of CLR assembly on deployment environment (and not the one that was used at the time of building dacpac)
Any help on this will be much appreciated.
Sorry I only picked on this thread now, but I had a similar issue.
Open the references in the Sql Server project, go to the dll that you are referencing right click and select properties.
Change the following settings:
Generate Sql Script: True
Model Aware: True
Select the relevant Permission set as required by the clr code.
I was able to solve this issue by including all the files in the bin/output folder that is built by the SSDT project on the machine that is deploying the dacpac. This folder includes all the referenced DLLs and DAPACs. I also included the publish.xml file and some sample SQLPackage cmd files in the build output to make it easy to deploy.
I found the answer from a post by Richard Gavel in the SQL Server Data Tools forum.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/aba60b70-396f-4624-890c-015c1f2d68f7/dacpac-dependencies-for-sqlpackageexe?forum=ssdt
I don't know if this helps but I was having trouble running SqlPackage /Action:Script between my compiled DACPAC and an extracted DACPAC and got a similar error (An error occurred while adding references). I resolved it by copying all the DACPACS from the \bin\debug directory of my DACPAC (it has about references to 15 other database projects plus master and msdb). After that, it worked. So it seems that in looking for references, it will check the directory first (I don't know if it was looking specifically at the current directory or the one the root DACPAC was in because those were one and the same).
We've recently started using Database Projects in Visual Studio 2013. So far, it's great!
There are some things we'd like to be able to customise and I'm not sure if it's even possible.
We'd like to be able to have our post-deployment scripts appended to the SQL that is generated when doing a schema compare, so that when we create a deployment script, it comes with our post-deployment stuff all in the one .sql file. Is there a way to do that?
Also, we'd like to know if there's a way that the .sql file that is generated can be customised (much like a .tt file can be for entity framework).
Welcome to SSDT!
Pre/Post deploy scripts don't get used by the schema compare so if you generate a lot of scripts then set up PowerShell or a batch file to call sqlpackage.exe and set the action to script. I use this as part of a CI build to generate scripts for different environments and works great.
You can customize the output by choosing what to include or exclude in the output script but if there is something not supplied out of the box you can modify it by using deployment contributors which you can add or remove steps or do things like add your own transactions etc, for more details see:
http://blogs.msdn.com/b/ssdt/archive/2013/12/23/dacfx-public-model-tutorial.aspx
If you let us know more about how you want to change it, there may be something already available to help.
Ed