### Sqitch Configuration File Example Source: https://sqitch.org/docs/manual/sqitch-configuration Provides an example of the default `sqitch.conf` file generated after project initialization. It shows common configuration settings like the default engine and commented-out options for plan files and top directories. ```ini [core] engine = pg # plan_file = sqitch.plan # top_dir = . ``` -------------------------------- ### Sqitch Project Configuration Example Source: https://sqitch.org/docs/manual/sqitch-configuration Illustrates a typical Sqitch project configuration file, specifying the default database engine and its associated client. ```ini [core] # default engine engine = pg [engine "pg"] # target = db:pg: registry = sqitch client = psql ``` -------------------------------- ### Initialize Git Repository Source: https://sqitch.org/docs/manual/sqitchtutorial Initializes a new Git repository for the project, creates a README file, and commits the initial project setup. ```bash mkdir flipr cd flipr git init . Initialized empty Git repository in /flipr/.git/ touch README.md git add . git commit -am 'Initialize project, add README.' ``` -------------------------------- ### Sqitch Deploy Workflow Example Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Illustrates the commands used to deploy a database schema change with Sqitch and verify the deployment using an external tool. ```bash > sqitch deploy Deploying changes to flipr_test + userflips .. ok ``` ```bash > exaplus -q -u sys -p exasol -c localhost:8563 -sql "describe flipr.userflips;" COLUMN_NAME SQL_TYPE NULLABLE DISTRIBUTION_KEY -------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------- -------- ---------------- ID DECIMAL(18,0) NICKNAME VARCHAR(64) UTF8 FULLNAME VARCHAR(256) UTF8 TWITTER VARCHAR(256) UTF8 BODY VARCHAR(180) UTF8 TS TIMESTAMP WITH LOCAL TIME ZONE ``` -------------------------------- ### Sqitch Help Synopsis Source: https://sqitch.org/docs/manual/sqitch-help Displays the command-line synopsis for the sqitch-help command. It shows how to get general help, help for specific commands, or a list of available guides. ```shell sqitch help [COMMAND] sqitch help --guide ``` -------------------------------- ### Sqitch Configuration File Example Source: https://sqitch.org/docs/manual/sqitch-configuration An example of the Sqitch configuration file (`sqitch.conf`) generated when adding a new engine. It defines the default engine and specific settings for a named engine. ```ini [core] engine = pg [engine "pg"] target = db:pg: top_dir = pg ``` -------------------------------- ### Sqitch Configuration Example Source: https://sqitch.org/docs/manual/sqitch-config An example of a Sqitch configuration file demonstrating sections, subsections, and variable assignments for core settings, engine configurations, and reversion strategies. ```config # Core variables [core] engine = pg top_dir = migrations extension = ddl [engine "pg"] registry = widgetopolis [revert] to = gamma [bundle] from = gamma tags_only = yes dest_dir = _build/sql ``` -------------------------------- ### Sqitch Configuration File Format Example Source: https://sqitch.org/docs/manual/sqitch-config An example illustrating the basic format of a Sqitch configuration file, including comments and key-value pairs. ```APIDOC Sqitch Configuration File Format Example: ``` # # This is the config file, and # a '#' or ';' character indicates # a comment ``` ``` -------------------------------- ### Sqitch User Configuration File Example Source: https://sqitch.org/docs/manual/sqitchtutorial-vertica Illustrates the content of the `~/.sqitch/sqitch.conf` file after setting user-specific configurations for the Vertica engine and user details. ```ini [engine "vertica"] client = /opt/vertica/bin/vsql [user] name = Marge N. O’Vera email = marge@example.com ``` -------------------------------- ### Git Commit Example Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Demonstrates adding changes to the staging area and committing them with a descriptive message. Includes output showing files changed and their status. ```git > git add . > git commit -m 'Add the twitter column to the userflips view.' [main 95d6dd0] Add the twitter column to the userflips view. 7 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 deploy/userflips@v1.0.0-dev2.sql create mode 100644 revert/userflips@v1.0.0-dev2.sql create mode 100644 verify/userflips@v1.0.0-dev2.sql ``` -------------------------------- ### Sqitch Revert Workflow Example Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Demonstrates the commands used to revert a database schema change with Sqitch and verify the reversion. ```bash > sqitch revert --to @HEAD^ -y Reverting changes to hashtags @v1.0.0-dev2 from flipr_test - userflips .. ok ``` ```bash > exaplus -q -u sys -p exasol -c localhost:8563 -sql "describe flipr.userflips;" COLUMN_NAME SQL_TYPE NULLABLE DISTRIBUTION_KEY -------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------- -------- ---------------- ID DECIMAL(18,0) NICKNAME VARCHAR(64) UTF8 FULLNAME VARCHAR(256) UTF8 BODY VARCHAR(180) UTF8 TS TIMESTAMP WITH LOCAL TIME ZONE ``` -------------------------------- ### Sqitch Deploy Command Example Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol An example of the 'sqitch deploy' command, which applies pending database schema changes to the target database. It indicates which changes are being deployed and their status. ```shell > sqitch deploy Deploying changes to flipr_test + users .. ok ``` -------------------------------- ### Sqitch Upgrade Example: Specifying Client Path Source: https://sqitch.org/docs/manual/sqitch-upgrade An example demonstrating how to specify the path to the database client command-line tool when running sqitch-upgrade. ```shell sqitch upgrade --client /usr/local/pgsql/bin/psql ``` -------------------------------- ### Sqitch Upgrade Example: Specifying Database Host Source: https://sqitch.org/docs/manual/sqitch-upgrade An example demonstrating how to specify the database host using the --db-host option for the sqitch-upgrade command. ```shell sqitch upgrade --db-host db.example.com ``` -------------------------------- ### Git Add and Commit Example Source: https://sqitch.org/docs/manual/sqitchtutorial-vertica Shows standard Git commands for staging changes and committing them to the repository. This is a common step before deploying database changes. ```shell > git add . > git commit -m 'Add flipr schema.' [main 9bee4bd] Add flipr schema. 5 files changed, 197 insertions(+), 0 deletions(-) create mode 100644 deploy/appschema.sql create mode 100644 revert/appschema.sql create mode 100644 sqitch.sql create mode 100644 verify/appschema.sql ``` -------------------------------- ### Sqitch Tag Command Examples Source: https://sqitch.org/docs/manual/sqitch-tag Provides practical examples of using the sqitch-tag command for various scenarios, including listing tags, tagging specific changes, applying tags to all plans, and specifying notes. ```APIDOC Sqitch Tag Command Examples: # Get a list of tags in the default project plan: sqitch tag # Get a list of all tags in the project: sqitch tag --all # Get a list of the tags in the plan used by the 'pg' engine: sqitch tag pg # Get a list of the tags in two specific plans: sqitch tag sqlite.plan pg.plan # Tag the latest change in the default project plan and be prompted for a note: sqitch tag alpha1 # Tag the latest change in all project plans and be prompted for a note: sqitch tag alpha1 --all # Tag the latest change in the default project plan and specify the note: sqitch tag alpha2 -n 'Tag @alpha2.' # Tag change 'users' in the default plan: sqitch tag --tag alpha3 --change users # Tag the latest change change in the project plan used by the 'vertica' engine: sqitch tag --tag beta1 vertica -n 'Tag the Vertica with @beta1.' # Tag the latest change in two plans in a project: sqitch tag -t v1.0.1 sqlite.plan pg.plan -n 'Tag @v1.0.1.' ``` -------------------------------- ### Sqitch Upgrade Example: Specifying Database Port Source: https://sqitch.org/docs/manual/sqitch-upgrade An example showing how to specify the database port using the --db-port option when running sqitch-upgrade. ```shell sqitch upgrade --db-port 5431 ``` -------------------------------- ### Sqitch Log Command Example Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Illustrates the `sqitch log` command, which displays the deployment history of a database project. The output shows both revert and deploy actions for a specific change. ```shell > sqitch log 'db:exasol://sys:exasol@localhost:8563/?Driver=Exasol' On database db:exasol://sys:@localhost:8563/?Driver=Exasol Revert f9759f0ed77964b6a3b6c7aa3b6058b4bb7db764 Name: appschema Committer: Marge N. O’Vera Date: 2014-09-04 16:33:02 -0700 Add schema for all flipr objects. Deploy f9759f0ed77964b6a3b6c7aa3b6058b4bb7db764 Name: appschema Committer: Marge N. O’Vera Date: 2014-09-04 15:26:28 -0700 Add schema for all flipr objects. ``` -------------------------------- ### Exasol Schema Query Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol An example SQL query executed via the `exaplus` command-line tool to list all schema names in an Exasol database. This is used to verify that a deployment was successful. ```shell > exaplus -q -u sys -p exasol -c localhost:8563 -sql "select schema_name from exa_schemas;" SCHEMA_NAME -------------------------------------------------------------------------------------------------------------------------------- SQITCH FLIPR ``` -------------------------------- ### Sqitch Status Command Example Source: https://sqitch.org/docs/manual/sqitchtutorial Shows the output of the `sqitch status` command, detailing the current database, project, last deployed change, and confirming that the database is up-to-date. ```shell > sqitch status # On database flipr_test # Project: flipr # Change: 77398e1dbc5fbce58b05eb67d201f15774718727 # Name: users # Deployed: 2013-12-30 15:57:14 -0800 # By: Marge N. O’Vera # Nothing to deploy (up-to-date) ``` -------------------------------- ### Sqitch Verify Command Example Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Demonstrates the usage of the `sqitch verify` command to check the current state of database changes. It shows the output when no changes are deployed. ```shell > sqitch verify 'db:exasol://sys:exasol@localhost:8563/?Driver=Exasol' Verifying db:exasol://sys:@localhost:8563/?Driver=Exasol No changes deployed ``` -------------------------------- ### Show Sqitch Target Configurations Source: https://sqitch.org/docs/manual/sqitch-configuration Displays the detailed configuration settings for one or more Sqitch targets, including URI, registry, client, and script directories. ```shell > sqitch target show prod-primary prod-standby ``` ```shell > sqitch target show dev-sqlite ``` -------------------------------- ### Initialize Git Repository and Project Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Commands to create a new project directory, initialize a Git repository, add a README file, and commit the initial project state. This sets up version control for the project. ```shell > mkdir flipr > cd flipr > git init . Initialized empty Git repository in /flipr/.git/ > touch README.md > git add . > git commit -am 'Initialize project, add README.' ``` -------------------------------- ### Deploy to Default PostgreSQL Database Source: https://sqitch.org/docs/manual/sqitch-configuration A basic example of deploying changes to the default PostgreSQL database associated with the 'pg' engine configuration. ```bash sqitch deploy pg ``` -------------------------------- ### Sqitch Bundle Creation Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Demonstrates creating a deployable bundle of all project changes, including tagged versions, using `sqitch bundle`. The output lists the changes included in the bundle. ```shell > sqitch bundle Bundling into bundle Writing config Writing plan Writing scripts + appschema + users + flips + userflips @v1.0.0-dev1 ``` -------------------------------- ### Initialize Sqitch Project with Git Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Stages all project files and commits them to the Git repository, initializing the Sqitch configuration. ```bash > git add . > git commit -am 'Initialize Sqitch configuration.' ``` -------------------------------- ### Exasol Passwordless Authentication URI Source: https://sqitch.org/docs/manual/sqitch-authentication Example connection URI for Exasol using OpenID authentication with Sqitch. This method requires specifying AUTHMETHOD=refreshtoken in the target URI query string. ```uri db:exasol://sys:exasol@localhost:8563/?Driver=Exasol&AUTHMETHOD=refreshtoken ``` -------------------------------- ### Sqitch Configuration Management Commands Source: https://sqitch.org/docs/manual/sqitch-config Provides examples of using the `sqitch config` command to manage project settings, including setting, unsetting, getting, and replacing values, with support for multi-value settings and regular expressions. ```APIDOC Sqitch Configuration Commands: Set a configuration value: sqitch config Example: sqitch config bundle.tags_only true Set a configuration value with a regex for replacement: sqitch config Example: sqitch config core.fuzzle.clack hi '^foo$' Unset a configuration value: sqitch config --unset Example: sqitch config --unset bundle.from Unset a specific value from a multi-value setting using a regex: sqitch config --unset Example: sqitch config --unset core.fuzzle.clack '^bar$' Get a configuration value: sqitch config --get Example: sqitch config --get core.engine (Or simply: sqitch config ) Get values matching a regex from a multi-value setting: sqitch config --get Example: sqitch config --get core.fuzzle.clack ba Get all values for a multi-value setting: sqitch config --get-all Example: sqitch config --get-all core.fuzzle.clack Replace all values for a key: sqitch config --replace-all Example: sqitch config --replace-all core.fuzzle.clack funk Replace values matching a regex, excluding those matching another regex: sqitch config --replace-all Example: sqitch config --replace-all core.fuzzle.clack yow '!bar' Escape special characters in regex: Example: sqitch config section.key '[!]' Add a new setting without altering existing ones: sqitch config --add Example: sqitch config --add core.fuzzle.set widget=fred Configuration File Locations: - Project-local: ./sqitch.conf - Per-user: $HOME/.sqitch/sqitch.conf - System-wide: $($etc_prefix)/sqitch.conf Variable Naming Rules: - Case-insensitive. - Allow only alphanumeric characters and '-'. - Must start with an alphabetic character. - Some variables may appear multiple times (multi-value settings). ``` -------------------------------- ### Deploying Bundled Sqitch Project Source: https://sqitch.org/docs/manual/sqitchtutorial Demonstrates deploying a Sqitch project from a bundled directory to a new production database. ```shell > cd bundle > createdb flipr_prod > sqitch deploy db:pg:flipr_prod Adding registry tables to db:pg:flipr_prod Deploying changes to db:pg:flipr_prod + appschema ................. ok + users ..................... ok + insert_user ............... ok + change_pass @v1.0.0-dev1 .. ok ``` -------------------------------- ### Snowflake Connection URI with Key Pair Auth Source: https://sqitch.org/docs/manual/sqitch-authentication Example connection URIs for Snowflake using key-pair authentication with Sqitch. Demonstrates connecting via a named DSN or directly embedding ODBC parameters. ```uri db:snowflake://movera@example.snowflakecomputing.com/flipr?warehouse=compute_wh;DSN=sqitch ``` ```uri db:snowflake://movera@example.snowflakecomputing.com/flipr?Driver=Snowflake;warehouse=sqitch;authenticator=SNOWFLAKE_JWT;uid=movera;priv_key_file=path/to/privatekey.p8;priv_key_file_pwd=s0up3rs3cre7 ``` -------------------------------- ### Sqitch Deploy with Verification Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Demonstrates deploying changes to a database target using the `sqitch deploy` command with the `--verify` option. This ensures that verification scripts are run during deployment. ```shell > sqitch deploy --verify 'db:exasol://sys:exasol@localhost:8563/?Driver=Exasol' Deploying changes to db:exasol://sys:@localhost:8563/?Driver=Exasol + appschema .. ok ``` -------------------------------- ### Run Exasol Docker Instance Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Starts a detached Exasol Docker container, mapping the Exasol port to the host machine. This command is used to quickly set up an Exasol database for testing or development. ```shell > docker run --detach --privileged --stop-timeout 120 -p 127.0.0.1:8563:8888 exasol/docker-db:latest ``` -------------------------------- ### MySQL Password File (.my.cnf) Source: https://sqitch.org/docs/manual/sqitch-authentication Explains how MySQL credentials can be stored in configuration files like /etc/my.cnf or ~/.my.cnf when the MySQL::Config module is installed. These files must also have restricted permissions (0600). ```APIDOC MySQL Configuration File Sections: Sqitch looks for credentials under the [client] and [mysql] sections. Example ~/.my.cnf: [client] user=myuser password=mypassword Permissions: Configuration files must be restricted to the owner only (0600). ``` -------------------------------- ### Sqitch Deployment Plan Structure Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Displays the content of a `sqitch.plan` file, showing the project configuration, URI, and a list of planned database changes. Each entry includes the change name, dependencies, timestamp, author, and a note. ```sqitch %syntax-version=1.0.0 %project=flipr %uri=https://github.com/sqitchers/sqitch-exasol-intro/ appschema 2014-09-04T18:40:34Z Marge N. O’Vera # Add schema for all flipr objects. users [appschema] 2014-09-04T23:40:15Z Marge N. O’Vera # Creates table to track our users. flips [appschema users] 2014-09-05T00:16:58Z Marge N. O’Vera # Adds table for storing flips. userflips [appschema users flips] 2014-09-05T00:18:43Z Marge N. O’Vera # Creates the userflips view. ``` -------------------------------- ### Install DBD::Oracle Source: https://sqitch.org/docs/manual/sqitchtutorial-oracle Installs the DBD::Oracle Perl module using the cpanm installer. This module is necessary for Sqitch to interact with Oracle databases. ```shell cpanm DBD::Oracle ``` -------------------------------- ### Initialize Sqitch Project with PostgreSQL Source: https://sqitch.org/docs/manual/sqitch-configuration Demonstrates initializing a new Sqitch project named 'widgets' and configuring it to use the PostgreSQL database engine. Shows the command used and the typical output, including the creation of configuration and plan files. ```shell > sqitch init widgets --engine pg Created sqitch.conf Created sqitch.plan Created deploy/ Created revert/ Created verify/ ``` -------------------------------- ### Invalid Sqitch Tag Name Example Source: https://sqitch.org/docs/manual/sqitchchanges An example of a name that is valid for a Sqitch change but invalid for a Sqitch tag due to the presence of a slash. ```shell foo/bar ``` -------------------------------- ### Initialize Git Repository for Sqitch Project Source: https://sqitch.org/docs/manual/sqitchtutorial-sqlite Demonstrates the steps to create a new directory, initialize a Git repository, add a README file, and commit the initial project setup. This is a prerequisite for version-controlled database changes. ```shell > mkdir flipr > cd flipr > git init . Initialized empty Git repository in /flipr/.git/ > touch README.md > git add . > git commit -m 'Initialize project, add README.' [main (root-commit) 253542e] Initialize project, add README. 1 file changed, 37 insertions(+) create mode 100644 README.md ``` -------------------------------- ### Database Connection URI Examples Source: https://sqitch.org/docs/manual/sqitch-target Provides concrete examples of database connection URIs for various database engines, illustrating the syntax and usage of different components. ```APIDOC Examples: db:sqlite:widgets.db db:pg://dba@example.net/blanket db:mysql://db.example.com/ db:firebird://localhost//tmp/test.fdb db:pg://ro%7Cmichelle@examle.org/inventory db:snowflake://example/flipr?Driver=Snowflake;warehouse=%22sqitch.dev%22 ``` -------------------------------- ### Deploying Sqitch Bundle to a New Database Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Shows how to deploy a previously created Sqitch bundle to a new database instance, such as one running in Docker. It involves navigating into the bundle directory and using `sqitch deploy` with a database connection string. ```shell > docker run --detach --privileged --stop-timeout 120 -p 127.0.0.1:9999:8888 exasol/docker-db:latest > cd bundle > sqitch deploy 'db:exasol://sys:exasol@localhost:9999/?Driver=Exasol' Adding registry tables to db:exasol://sys:@localhost:9999/?Driver=Exasol Deploying changes to db:exasol://sys:@localhost:9999/?Driver=Exasol + appschema ............... ok + users ................... ok + flips ................... ok + userflips @v1.0.0-dev1 .. ok ``` -------------------------------- ### Sqitch Commands Overview Source: https://sqitch.org/docs/manual/sqitchtutorial Provides a summary of common Sqitch commands used for managing database deployments, including verify, status, and revert. ```apidoc Sqitch Commands: sqitch verify - Runs verification scripts for the current project against the specified target. - Ensures deployed changes meet expected criteria. sqitch status - Displays the current state of the Sqitch project's registry in the target database. - Shows which changes have been deployed and their metadata. sqitch revert - Rolls back the most recently deployed change from the target database. - Prompts for confirmation by default, can use -y to bypass. - Useful for undoing deployments or correcting errors. ``` -------------------------------- ### Sqitch Upgrade Example: Specifying Database User Source: https://sqitch.org/docs/manual/sqitch-upgrade An example illustrating the use of the --db-user option to set the username for connecting to the database during an upgrade. ```shell sqitch upgrade --db-user postgres ``` -------------------------------- ### Packaging and Distributing Sqitch Bundle Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Illustrates the final steps of packaging the bundled Sqitch project into a distributable archive (e.g., a `.tgz` file) after moving the bundle directory to a versioned name. ```shell > cd .. > mv bundle flipr-v1.0.0-dev1 > tar -czf flipr-v1.0.0-dev1.tgz flipr-v1.0.0-dev1 ``` -------------------------------- ### Sqitch Status Output Example Source: https://sqitch.org/docs/manual/sqitchtutorial-oracle An example output from the `sqitch status --show-tags` command, indicating the current state of changes applied to the database, including deployed status and tags. ```bash > sqitch status --show-tags # On database flipr_test # Project: flipr # Change: a47be5a474eaad1a28546666eadeb0eba3ac12dc # Name: delete_flip # Deployed: 2013-12-31 16:54:31 -0800 # By: Marge N. O’Vera # # Tag: # @v1.0.0-dev1 - 2013-12-31 16:44:00 -0800 - Marge N. O’Vera # Nothing to deploy (up-to-date) ``` -------------------------------- ### View Sqitch Configuration Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Displays the content of the sqitch.conf file, showing the core project settings such as the database engine and commented-out options for plan file and top directory. ```shell > cat sqitch.conf [core] engine = exasol # plan_file = sqitch.plan # top_dir = . ``` -------------------------------- ### Sqitch Upgrade Example: Specifying Database Name Source: https://sqitch.org/docs/manual/sqitch-upgrade An example showing how to use the --db-name option to specify the target database name for the sqitch-upgrade command. ```shell sqitch upgrade --db-name widgets ``` -------------------------------- ### Initialize Sqitch Project Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Initializes a new Sqitch project named 'flipr' with a specified URI and the 'exasol' engine. This command creates the necessary Sqitch configuration and directory structure. ```shell > sqitch init flipr --uri https://github.com/sqitchers/sqitch-exasol-intro/ --engine exasol Created sqitch.conf Created sqitch.plan Created deploy/ Created revert/ Created verify/ ``` -------------------------------- ### Database Table Check Example Source: https://sqitch.org/docs/manual/sqitchtutorial-firebird A command-line example using `isql-fb` to connect to a Firebird database and list its tables. This is used to verify that a table has been successfully removed after a Sqitch revert operation. ```shell > echo "CONNECT 'localhost:/tmp/flipr_test/flipr.fdb'; SHOW TABLES; quit;" \ | isql-fb -q -u SYSDBA -p masterkey There are no tables in this database ``` -------------------------------- ### Packaging Sqitch Bundle for Distribution Source: https://sqitch.org/docs/manual/sqitchtutorial Shows how to move the bundled project directory and create a compressed archive for distribution. ```shell > cd .. > mv bundle flipr-v1.0.0-dev1 > tar -czf flipr-v1.0.0-dev1.tgz flipr-v1.0.0-dev1 ``` -------------------------------- ### Git Add and Commit Example Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Demonstrates basic Git commands for staging changes ('git add .') and committing them with a message ('git commit -am'). This is crucial for version control before deploying database changes. ```shell > git add . > git commit -am 'Add users table.' [main c7c24c5] Add users table. 4 files changed, 18 insertions(+), 0 deletions(-) create mode 100644 deploy/users.sql create mode 100644 revert/users.sql create mode 100644 verify/users.sql ``` -------------------------------- ### Sqitch User Configuration Example Source: https://sqitch.org/docs/manual/sqitch An example of a user-specific Sqitch configuration file (`~/.sqitch/sqitch.conf`) used to define system-wide defaults, such as user identity and paths to database client executables for various database engines. ```config [user] name = Marge N. O’Vera email = marge@example.com [engine "pg"] client = /usr/local/pgsql/bin/psql [engine "mysql"] client = /usr/local/mysql/bin/mysql [engine "oracle"] client = /usr/local/instantclient_11_2/sqlplus [engine "sqlite"] client = /usr/local/bin/sqlite3 ``` -------------------------------- ### Sqitch Verify Failure Example (Divide by Zero) Source: https://sqitch.org/docs/manual/sqitchtutorial-vertica Shows the Sqitch verification failure output when using the divide-by-zero method to detect a missing schema. This example highlights the error message returned by the database for such conditions. ```shell > sqitch verify 'db:vertica://dbadmin:password@localhost:5433/dbadmin?Driver=Vertica' Verifying db:vertica://dbadmin:@localhost:5433/dbadmin?Driver=Vertica * appschema .. vsql:verify/appschema.sql:5: ERROR 2005: division by zero # Verify script "verify/appschema.sql" failed. not ok Verify Summary Report --------------------- Changes: 1 Errors: 1 Verify failed ``` -------------------------------- ### Initialize Sqitch Project Source: https://sqitch.org/docs/manual/sqitchtutorial Initializes a new Sqitch project with a specified name and URI, configuring it for PostgreSQL database engine. ```bash sqitch init flipr --uri https://github.com/sqitchers/sqitch-intro/ --engine pg Created sqitch.conf Created sqitch.plan Created deploy/ Created revert/ Created verify/ ``` -------------------------------- ### Sqitch Rework Command Example Source: https://sqitch.org/docs/manual/sqitchtutorial-mysql An example of using the `sqitch rework` command to modify a database change. This command is used to update the script associated with a specific change and update the Sqitch plan. ```shell > sqitch rework change_pass -n 'Change change_pass to use encyrpt().' ``` -------------------------------- ### Sqitch Project Configuration Example Source: https://sqitch.org/docs/manual/sqitch An example of a Sqitch project configuration file (`sqitch.conf`) that specifies core settings, engine-specific targets, revert strategies, and bundling options. This configuration is typically checked into version control for project-specific settings. ```config [core] engine = pg top_dir = migrations extension = ddl [engine "pg"] target = widgetopolis [revert] to = gamma [bundle] from = gamma tags_only = yes dest_dir = _build/sql [target "widgetopolis"] uri = db:pg:widgetopolis ``` -------------------------------- ### Initialize Git Repository and Project Files Source: https://sqitch.org/docs/manual/sqitchtutorial-vertica Commands to create a new project directory, initialize a Git repository, add a README file, and make the initial commit. ```shell > mkdir flipr > cd flipr > git init . Initialized empty Git repository in /flipr/.git/ > touch README.md > git add . > git commit -am 'Initialize project, add README.' ``` -------------------------------- ### Sqitch Deploy from Bundle Source: https://sqitch.org/docs/manual/sqitchtutorial-sqlite Shows how to deploy a Sqitch project from a bundled directory. This simulates deploying the packaged changes to a new database instance, confirming that tagged changes are correctly applied. ```shell > cd bundle > sqitch deploy db:sqlite:flipr_prod.db Adding registry tables to db:sqlite:sqitch.db Deploying changes to db:sqlite:flipr_prod.db + users ................... ok + flips ................... ok + userflips @v1.0.0-dev1 .. ok ``` -------------------------------- ### Sqitch Status After Deploy Example Source: https://sqitch.org/docs/manual/sqitchtutorial-snowflake Shows the output of `sqitch status` after a successful deployment. It indicates that the database is up-to-date with no pending changes to deploy. ```shell > sqitch status # Project: flipr # Change: d251b2c9b4bc46a4b4db6b7a8a637951484e6f6b # Name: users # Deployed: 2018-07-27 11:19:30 -0400 # By: Marge N. O’Vera # Nothing to deploy (up-to-date) ``` -------------------------------- ### Sqitch URI Configuration Source: https://sqitch.org/docs/manual/sqitch-configuration Specifies the database URI for Sqitch connections. This can be set through command-line options, environment variables, or target-specific configuration. ```APIDOC Sqitch URI Configuration: Specifies the database URI to which Sqitch connects. Configuration Hierarchy: 1. **Command target argument or option:** ```bash sqitch deploy $uri sqitch revert --target $uri ``` 2. **`$SQITCH_TARGET` environment variable:** ```bash env SQITCH_TARGET=$uri sqitch deploy env SQITCH_TARGET=$uri sqitch revert ``` 3. **Configuration variable `target.$target.uri`:** ```bash sqitch init $project --engine $engine --target $uri sqitch target add $target --uri $uri sqitch target alter $target --uri $uri ``` Parameters: - `$uri`: The database connection URI. ``` -------------------------------- ### Sqitch Bundle Command Source: https://sqitch.org/docs/manual/sqitchtutorial-sqlite Demonstrates the `sqitch bundle` command, which packages the project's plan, scripts, and configuration into a distributable format. The output shows the included changes and their tags. ```shell > rm -rf dev > sqitch bundle Bundling into bundle Writing config Writing plan Writing scripts + users + flips + userflips @v1.0.0-dev1 ``` -------------------------------- ### Deploy Changes to a Specific Sqitch Target Source: https://sqitch.org/docs/manual/sqitch-configuration Executes the Sqitch deploy command targeting a specific named database server configuration. ```shell > sqitch deploy prod-primary > sqitch deploy prod-standby ``` -------------------------------- ### Git Commit Sqitch Configuration Source: https://sqitch.org/docs/manual/sqitchtutorial-vertica Commits the initialized Sqitch configuration files (`sqitch.conf`, `sqitch.plan`) to Git. This records the project setup. ```shell > git add . > git commit -am 'Initialize Sqitch configuration.' ``` -------------------------------- ### Sqitch Deploy with Verification Source: https://sqitch.org/docs/manual/sqitchtutorial Demonstrates deploying database changes to a target database while ensuring that verification scripts are run. The output confirms the successful deployment of the 'appschema' change. ```shell > sqitch deploy --verify db:pg:flipr_test Deploying changes to db:pg:flipr_test + appschema .. ok ``` -------------------------------- ### Sqitch Status Command Example Source: https://sqitch.org/docs/manual/sqitchtutorial-vertica Displays the current status of database changes relative to the project. It shows if changes are deployed, pending, or up-to-date. ```shell > sqitch status 'db:vertica://dbadmin:password@localhost:5433/dbadmin?Driver=Vertica' # On database db:vertica://dbadmin:@localhost:5433/dbadmin?Driver=Vertica # Project: flipr # Change: f9759f0ed77964b6a3b6c7aa3b6058b4bb7db764 # Name: appschema # Deployed: 2014-09-04 16:37:38 -0700 # By: Marge N. O’Vera # Nothing to deploy (up-to-date) ``` -------------------------------- ### Deploy Database Changes with Sqitch Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Initiates the deployment of all pending database changes to the target Exasol database using a provided connection URI. ```bash > sqitch deploy 'db:exasol://sys:exasol@localhost:8563/?Driver=Exasol' ``` -------------------------------- ### Deploy Changes to Multiple Sqitch Targets Source: https://sqitch.org/docs/manual/sqitch-configuration Iterates through a list of targets (e.g., all targets matching a pattern) and deploys changes to each one sequentially. ```shell for target in `sqitch target | grep prod-`; do sqitch deploy $target done ``` -------------------------------- ### Initialize Sqitch Project Source: https://sqitch.org/docs/manual/sqitchtutorial-oracle Commands to initialize a new Sqitch project, creating essential configuration and directory structure. This includes the sqitch.conf, sqitch.plan, and directories for deploy, revert, and verify scripts. ```shell Created sqitch.conf Created sqitch.plan Created deploy/ Created revert/ Created verify/ ``` -------------------------------- ### Initialize Sqitch Project Source: https://sqitch.org/docs/manual/sqitchtutorial-vertica Initializes a new Sqitch project with a specified name, URI, and database engine. This command creates essential project directories and configuration files. ```shell > sqitch init flipr --uri https://github.com/sqitchers/sqitch-vertica-intro/ --engine vertica Created sqitch.conf Created sqitch.plan Created deploy/ Created revert/ Created verify/ ``` -------------------------------- ### Initialize Git Repository Source: https://sqitch.org/docs/manual/sqitchtutorial-snowflake Demonstrates the initial steps to create a new project directory, initialize a Git repository, add a README file, and make the first commit. This sets up the foundational version control for the project. ```shell > mkdir flipr > cd flipr > git init . Initialized empty Git repository in /flipr/.git/ > touch README.md > git add . > git commit -am 'Initialize project, add README.' ``` -------------------------------- ### Sqitch Verify Command Example Source: https://sqitch.org/docs/manual/sqitchtutorial-vertica Demonstrates the Sqitch verify command to check the current state of database changes. It shows the output when no changes are deployed. ```shell > sqitch verify 'db:vertica://dbadmin:@localhost:5433/dbadmin?Driver=Vertica' Verifying db:vertica://dbadmin:@localhost:5433/dbadmin?Driver=Vertica No changes deployed ``` -------------------------------- ### View Sqitch User Configuration Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol Displays the content of the user-specific Sqitch configuration file, showing the applied engine and user settings. ```bash > cat ~/.sqitch/sqitch.conf ``` -------------------------------- ### Sqitch Deploy Command Example Source: https://sqitch.org/docs/manual/sqitchtutorial-snowflake Illustrates the `sqitch deploy` command, which applies pending database changes to the target database. It reports the success or failure of each applied change. ```shell > sqitch deploy Deploying changes to flipr_test + users .. ok ``` -------------------------------- ### Sqitch Log Command Example Source: https://sqitch.org/docs/manual/sqitchtutorial Demonstrates the output of the `sqitch log` command, showing the deployment and revert history of database changes. The output is presented in reverse chronological order, with the most recent action (revert) listed first. ```shell > sqitch log db:pg:flipr_test On database db:pg:flipr_test Revert c7981df861183412b01be706889e508a63d445ca Name: appschema Committer: Marge N. O’Vera Date: 2013-12-30 15:38:17 -0800 Add schema for all flipr objects. Deploy c7981df861183412b01be706889e508a63d445ca Name: appschema Committer: Marge N. O’Vera Date: 2013-12-30 15:27:15 -0800 Add schema for all flipr objects. ``` -------------------------------- ### Sqitch Deploy Script with CREATE USER Source: https://sqitch.org/docs/manual/sqitchtutorial-mysql An example of a Sqitch deploy script modified to include a CREATE USER statement for a database. ```sql -- Deploy flipr:users to mysql BEGIN; CREATE USER flipr; COMMIT; ``` -------------------------------- ### Sqitch Plan File Configuration Source: https://sqitch.org/docs/manual/sqitch-configuration Sets the project deployment plan file. Defaults to '$top_dir/sqitch.plan'. Can be specified using command-line flags or configuration variables. ```APIDOC Sqitch Plan File Configuration: Specifies the project deployment plan file. Configuration Hierarchy: 1. **`--plan-file` or `-f` command-line option:** ```bash sqitch $command --plan-file $plan_file ``` 2. **Configuration variable `target.$target.plan_file`:** ```bash sqitch target add $target --plan-file $plan_file sqitch target alter $target --plan-file $plan_file ``` 3. **Configuration variable `engine.$engine.plan_file`:** ```bash sqitch engine add $engine --plan-file $plan_file sqitch engine alter $engine --plan-file $plan_file ``` 4. **Configuration variable `core.plan_file`:** ```bash sqitch init $project --plan-file $plan_file sqitch config core.plan_file $plan_file ``` Parameters: - `$plan_file`: The path to the Sqitch plan file. ``` -------------------------------- ### SQL Scripts for Users Table Source: https://sqitch.org/docs/manual/sqitchtutorial-exasol SQL statements for managing the 'users' table. Includes the CREATE TABLE statement for deployment, a SELECT statement with a FALSE WHERE clause for verification, and a DROP TABLE statement for reversion. ```sql -- Deploy flipr:users to exasol -- requires: appschema CREATE TABLE flipr.users ( nickname VARCHAR(64) PRIMARY KEY, password VARCHAR(256) NOT NULL, fullname VARCHAR(256) NOT NULL, twitter VARCHAR(256) NOT NULL, ts TIMESTAMP WITH LOCAL TIME ZONE DEFAULT NOW() NOT NULL ); COMMIT; ``` ```sql SELECT nickname, password, fullname, twitter, ts FROM flipr.users WHERE FALSE; ``` ```sql DROP TABLE flipr.users; ```