Hello everyone,
I'm building a deployment script using SQLcl Projects and Git, and I'm facing an issue where my deployments are not incremental as I expect them to be.
My current workflow is as follows:
- I create a new feature branch from my
main
branch (e.g., git checkout -b JIRA-123
).
- I apply the necessary changes to my development database schema.
- I run
project export
to capture the current state of the database objects into the src/
directory.
- I then run
project stage -verbose
. This command correctly shows me only the objects that have been modified or are new for this release.
- Next, I run
project release -version JIRA-123
to create the Git tag for the new version.
- After committing, pushing, and merging the changes, I connect to my target environment (e.g., Production).
- I generate the artifact using
project gen-artifact -version JIRA-123 ...
.
The Problem: When I use project deploy
with the artifact generated in the last step, it tries to deploy all objects from the project, not just the incremental changes associated with the JIRA-123
version. My expectation was that it would only apply the specific changes that project stage
had identified earlier.
Here is the script I am using:
-- Define variables based on parameters
DEFINE var1 = '&1' -- dev connection name
DEFINE var2 = '&2' -- jira id
DEFINE var3 = '&3' -- prod connection name
DEFINE var4 = '&4' -- db schema
-- Show defined values
prompt 'DEV connection name: ' &var1
prompt 'Jira ID: ' &var2
prompt 'PROD connection name: ' &var3
prompt 'DB Schema: ' &var4
-- Connect to the database using the connection name
connect -name &var1
-- Pull the latest changes from the repository
!git pull
-- Create and switch to a new branch
!git checkout -b &var2
-- Export the project
project export
!pause
-- Add src folder and commit the export
!git add src
!git commit -m "Export files for jira - &var2"
!git push -u origin &var2 --!git push origin 1.1
!pause
project stage -verbose
!pause
project release -version &var2 -verbose
-- Commit and merge the version
!git add .
!git commit -m "Version jira - &var2"
!git push origin &var2
-- Merge
!git checkout main
!git merge &var2
!pause
!git push origin main
-- Connect to PROD
connect -name &var3
!pause
-- Generate the artifact
project gen-artifact -name &var4 -version &var2 -format zip -verbose
!pause
-- Deploy the artifact
project deploy -file artifact/&var4-&var2..zip -verbose
My Question: Is my understanding of the workflow incorrect, or is my command order wrong? Does project gen-artifact
always package the entire project state from the filesystem, regardless of the version tag passed to it? If so, what is the correct approach to generate an artifact or a script that contains only the incremental changes for a specific release?
Any help or clarification would be greatly appreciated.
Thank you!