User Tools

Site Tools


dev:sqitch

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dev:sqitch [2016/03/25 13:43] ericksondev:sqitch [2022/02/10 13:34] (current) – external edit 127.0.0.1
Line 1: Line 1:
-==== Using Sqitch with Evergreen ====+===== Using Sqitch with Evergreen =====
  
 See also[[https://bugs.launchpad.net/evergreen/+bug/1521693|Launchpad Bug 1521693]] See also[[https://bugs.launchpad.net/evergreen/+bug/1521693|Launchpad Bug 1521693]]
  
  
-=== Getting Started ===+==== Getting Started ====
  
-== Install Sqitch ==+=== Install Sqitch ===
  
 <code> <code>
Line 13: Line 13:
 </code> </code>
  
-== Install Base Schema ==+=== Install Base Schema ===
  
 Install the latest working branch from LP 1521693 using the standard DB install process.  The branch is set up to use Sqitch internally.  No special considerations are required for the base install. Install the latest working branch from LP 1521693 using the standard DB install process.  The branch is set up to use Sqitch internally.  No special considerations are required for the base install.
  
-=== Creating an Upgrade Script ===+==== Creating an Upgrade Script ====
  
 For this example, we're cross-porting an existing SQL upgrade script for LP #1319998. For this example, we're cross-porting an existing SQL upgrade script for LP #1319998.
Line 23: Line 23:
 Full code is tracked in [[http://git.evergreen-ils.org/?p=working/Evergreen.git;a=commitdiff;h=c999d04|commit c999d04]]. Full code is tracked in [[http://git.evergreen-ils.org/?p=working/Evergreen.git;a=commitdiff;h=c999d04|commit c999d04]].
  
-**Override Sqitch DB connections parameters the sqitch flags --db-host, --db-name, --db-port, and/or --db-user.  The PGPASSWORD environment variable is also honored.**+**Override Sqitch DB connections parameters the sqitch flags --db-host, --db-name, --db-port, and --db-user.  The PGPASSWORD environment variable is also honored.**
  
 <code> <code>
Line 51: Line 51:
 For example, see the contents of these 3 files at [[http://git.evergreen-ils.org/?p=working/Evergreen.git;a=commitdiff;h=c999d04|commit c999d04]]. For example, see the contents of these 3 files at [[http://git.evergreen-ils.org/?p=working/Evergreen.git;a=commitdiff;h=c999d04|commit c999d04]].
  
-=== Deploying an Upgrade Script ===+==== Deploying an Upgrade Script ====
  
   * Sanity check the status first   * Sanity check the status first
Line 86: Line 86:
   - schema.materialized_billing_summary_delete_trigger .. ok   - schema.materialized_billing_summary_delete_trigger .. ok
 </code> </code>
 +
 +==== Resolving Conflicts / Deploying Multiple Plan Files ====
 +
 +**AKA "Cannot find this change in sqitch.plan"**
 +
 +When deploying changes, Sqitch inspects both the name and position of each target in the sqitch.plan file.  A Sqitch install target is a product of its name and which target precedes it.  (This is similar to Git commits). I had originally assumed only the name of the change mattered, so this was unexpected.  
 +
 +In an environment where changes are always deployed linearly, like a production database, this has no bearing.  However, when using Sqitch on a development database, where changes from different Git branches may be deployed in a single database, this can cause confusion for Sqitch.  When the sqitch.plan file does not match the events tracked in the Sqitch database tables, a sqitch deploy may result in an error like this:
 +
 +<code>
 +# On database evergreen
 +# Project:  evergreen
 +# Change:   e29fe26ba146d263e3494cc07960ecf2b26b620d
 +# Name:     schema.fix_vandelay_stored_procs
 +# Deployed: 2016-03-30 10:16:33 -0400
 +# By:       Bill Erickson <foo@example.org>
 +#
 +Cannot find this change in sqitch.plan
 +Make sure you are connected to the proper database for this project.
 +</code>
 +
 + 
 +The solution is to revert any Sqitch targets that are not shared by both branches.  The offending targets can be completely rolled back using 
 +
 +<code>
 +sqitch revert --to <last-shared-change>
 +</code>
 +
 +Or they can be virtually rolled back by telling Sqitch to pretend like they were reverted using
 +
 +<code>
 +sqitch revert --log-only --to <last-shared-change>
 +</code>  
 +
 +The **--log-only** option tells Sqitch to update its tracking tables without executing any deploy/verify/revert scripts.  This is particularly useful when bouncing between branches where you may not want to revert changes, because it means deleting test data.
 +
 +=== Example ===
 +
 +  - Deploy sqitch.plan with changes A, B, and C.
 +  - Checkout another Git branch with a sqitch.plan file containing changes A, B, D.
 +  - 'sqitch deploy' will result in error "Cannot find this change in sqitch.plan" with Name: C
 +  - Revert all offending changes:
 +<code>
 +# roll back the change.
 +sqitch revert --to B
 +
 +# OR just tell Sqitch to ignore the change.
 +sqitch revert --to B --log-only
 +</code>
 +  - Deploy change D
 +<code>
 +sqitch deploy
 +</code>
 +
 +The same steps will work when returning to the original branch w/ changes A, B, and C.
 + 
 +=== The --merge option ===
 +
 +Version 1.1.0 of Sqitch [[https://github.com/theory/sqitch/issues/200|will support]] a --merge option to better handle situations where the plan file does not match the exact order of the events tracked in the Sqitch database.  (At time of writing, CPAN installs version 0.9994).  In theory, this will make it easier to use a single database for developing across multiple branches.
 +
 +
dev/sqitch.1458927800.txt.gz · Last modified: 2022/02/10 13:34 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki

© 2008-2022 GPLS and others. Evergreen is open source software, freely licensed under GNU GPLv2 or later.
The Evergreen Project is a U.S. 501(c)3 non-profit organization.