Comments
5 comments
-
Hi @Monday,
The difference is that Invoke-DatabaseBuild is actually building the project on the shadow database to verify it, which is needed for the snapshot to be created. The New-DatabaseProjectObject just passes the files through into the correct object type, assuming you have validated externally.
From this page:Shadow database
The shadow database is a temporary database where SQL Change Automation can run your migration scripts. By running the migration scripts on a real database, SQL Server will check that they are valid SQL with no syntax errors, missing dependencies, etc.
As part of the shadow deployment process, a file containing a snapshot of your schema is produced and, upon deployment, will be inserted into the target database. During subsequent builds, the snapshot will be retrieved from the target database and used to generate the deployment preview and drift reports mentioned above. If at deployment time a snapshot file cannot be not found (i.e. because the shadow was not deployed at build time), a warning will be raised to indicate the impact to report generation.
Kind regards,
Alex -
So the snapshot is of the shadow database and not the target database? It used for drift? I was thinking it was a reference to what the target DB schema looked like before deployment.
-
Hi @Monday,
The snapshot is the "current schema" so on subsequent deployments from the first it compares the current (what's being deployed) to the previous snapshot (what's on the deployment target); there is no previous entry for the first deployment which is why the drift and diff reports are not able to be done the first time.
Kind regards,
Alex -
So when this command is run: Use-DatabaseReleaseArtifact $DBUpdate -DeployTo $DBConnection
The snaphot is the "current schema" of the -DeployTo target? If so it should not matter if a shadow database was created or not since shadow schema should not be used. When I run Invoke-DatabaseBuild and it creates the shadow database it does not know what my target is going to be at that time so I am a little confused at which schema is actually being used for the snapshot.
-
The snapshot is the current schema of the project (i.e. the shadow, which is created from the project, which is why the shadow database is needed to make it), and not the target. This snapshot is then compared to the current schema of the target database to create the drift report. It is compared to the previously deployed snapshot to create the diff report.
Add comment
Please sign in to leave a comment.
I am trying to avoid using Invoke-DatabaseBuild because it takes around 30 mins and frankly I am never going to rebuild the database from scratch using scripts anyway. I don't see why Use-DatabaseReleaseArtifact should be affected by this.
Here is a sample script which can be run either way without the specific variables declared.