Hydromast
Hydromast

Reputation: 312

How do I force the creation of tables using SQLPackage after renaming the table in the pre-deploy script?

According to this answer to another question, I should be able to rename an existing table in a pre-deployment script and that the dacpac should recreate the original table during the deployment process. However, the problem that I encountered is that the table doesn't get recreated and instead I get errors when a view or stored procedure uses that table. Is there a way to force the creation of a renamed table with the original name during the deployment process?

I did used the /Properties:CreateNewDatabase=True but it did not seem to work.

Upvotes: 0

Views: 734

Answers (1)

Martin Cairney
Martin Cairney

Reputation: 1767

The CreateNewDatabase option is defined as "Specifies whether the target database should be updated or whether it should be dropped and re-created when you publish to a database."

Therefore to keep the renamed table you need to perform an update and therefore /Properties:CreateNewDatabase=False

I think you need the following switche included:

DropObjectsNotInSource=FALSE Specifies whether objects that do not exist in the database snapshot (.dacpac) file will be dropped from the target database when you publish to a database. This value takes precedence over DropExtendedProperties.

/Properties:BlockWhenDriftDetected=False Specifies whether to block updating a database whose schema no longer matches its registration or is unregistered.

Upvotes: 1

Related Questions