GithubHelp home page GithubHelp logo

isabella232 / migration_tools Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zendesk/migration_tools

0.0 0.0 0.0 108 KB

Rake tasks for Rails that add groups to migrations

License: Apache License 2.0

Ruby 100.00%

migration_tools's Introduction

Migration Tools Build Status

Rake tasks for grouping migrations.

Groups

The migration tools allow you to specify a group in your migrations. This is used to allow you to run your migrations in groups, as opposed to all at once. This is useful if you want to run a certain group of migrations before a deploy, another group during deploy and a third group after deploy.

We use this technique to be able to QA new production code in an isolated environment that runs against the production database. It also reduces the number of moving parts come deploy time, which is helpful when you're doing zero downtime deploys.

You specify which group a migration belongs to inside the migration, like so:

  class CreateHello < ActiveRecord::Migration
    group :before

    def self.up
      ...
    end
  end

The names of the possible groups are predefined to avoid turning this solution in to a generic hammer from hell. You can use the following groups: before, during, after, change. We define these as:

before this is for migrations that are safe to run before a deploy of new code, e.g. adding columns/tables

during this is for migrations that require the data structure and code to deploy "synchronously"

after this is for migrations that should run after the new code has been pushed and is running

change this is a special group that you run whenever you want to change DB data which you'd otherwise do in script/console

Commands

The list commands

  $ rake db:migrate:list - shows pending migrations by group
  $ rake db:migrate:list:before - shows pending migrations for the before group
  $ rake db:migrate:list:during - shows pending migrations for the during group
  $ rake db:migrate:list:after  - shows pending migrations for the after group
  $ rake db:migrate:list:change - shows pending migrations for the change group

The group commands

  $ GROUP=before rake db:migrate:group - runs the migrations in the specified group
  $ rake db:migrate:group:before - runs pending migrations for the before group
  $ rake db:migrate:group:during - runs pending migrations for the during group
  $ rake db:migrate:group:after  - runs pending migrations for the after group
  $ rake db:migrate:group:change - runs pending migrations for the change group

Note that rake db:migrate is entirely unaffected by this.

License

Copyright 2015 Zendesk

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

migration_tools's People

Contributors

bquorning avatar dragonfax avatar grosser avatar icorson3 avatar morten avatar osheroff avatar pschambacher avatar sathishavm avatar staugaard avatar steved avatar vanchi-zendesk avatar zdennis avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.