Skip to content

Instantly share code, notes, and snippets.

@relistan
Created March 31, 2012 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save relistan/2262674 to your computer and use it in GitHub Desktop.
Save relistan/2262674 to your computer and use it in GitHub Desktop.
Deployment with Git detection of pending migrations

Helpful Git Commands

These are some useful git commands for implementing this in your own deployment setup.

Detecting if we're running on a clean checkout:

  • git fetch
  • git diff --shortstat [branch]

Determining if there are pending migrations:

  • git diff --shortstat [last_tag] [branch] db/migrate

Displaying new migrations in list form:

  • git diff --summary [last_tag] [branch] db/migrate

Adding new tags (you want to annotate your tags):

  • git tag -a [new_tag] -m "annotation for tag"
  • git push --tags

Deleting a tag:

  • git tag -d [tag]
  • git push --tags
sleipnir:api karl$ cap production deploy
* 15:00:36 == Currently executing `production'
triggering start callbacks for `deploy'
* 15:00:36 == Currently executing `multistage:ensure'
* 15:00:36 == Currently executing `deploy'
triggering before callbacks for `deploy'
*** Deploying HEAD from branch 'master' to 'production'
*** Pending migrations!!!
create mode 100644 db/migrate/20120327113515_store_info_in_alerts.rb
create mode 100644 db/migrate/20120327190626_add_pending_data_table.rb
create mode 100644 db/migrate/20120329102140_populate_pending_data_table.rb
Do you want to continue deployment? (Y/N)
n
*** Aborting deployment!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment