Applies to:
- Liquibase Pro
Summary:
The following example outlines how to set up two projects in AWS where one will generate a snapshot after each deployment in CodeBuild, and the other will run the diff operation on demand.
Environment Conditions:
- AWS CodeBuild
- Liquibase Pro
How to set up a project that produces the snapshot:
- Configure the project to use an S3 bucket as your artifact
Configure your buildspec.yml as follows:
- As part of each deployment operation, generate the latest snapshot file from the database and store the snapshot in your S3 bucket.
- Generate a snapshot file “snapshot-dev.json” (see line 34 in the image below)
- Store the artifact in your S3 bucket (see lines 36-38 in the image below)
How to set up a project that runs diff (consuming the snapshot):
- Configure the project with an S3 bucket as your second source (assuming the first source points to your repository with buildspec.yml to run the "diff" command). In the CodeBuild project, click on Edit Source.
- Click "Add Source"
- Specify your S3 bucket as your second source. If necessary, specify a folder in your S3 bucket containing your snapshot file.
Configure your buildspec.yml as follows:
- Specify the URL to the snapshot file as an environment variable or a command line argument:
- Environment variable example:
-
LIQUIBASE_COMMAND_REFERENCE_URL: offline:postgresql?snapshot=<snapshot_file>
-
- Command line example:
-
--reference-url=offline:postgresql?snapshot=<snapshot_file>
-
- Environment variable example:
- For each source configured in the CodeBuild project, CodeBuild will automatically create an environment variable, e.g., “CODEBUILD_SRC_DIR_S3syngentademo”, to indicate the source directory and can be used in the buildspec.yml file. The example below use this in line 33 to “cd” to this directory and then run the “liquibase diff” operation.
Comments
0 comments
Article is closed for comments.