<commit_before># Transitions

Transitions aims to remove traditional ActiveRecord migrations and replace it with DataMapper-like automatic migrations mixed with event based data patching.

The major advantage of Transitions over migrations is that it allows Rails engines to define there own schemas which get automatically loaded in the application. The application remains in full control as it can overwrite an engines schema.

## Quick Start Guide

    #!/usr/bin/env bash
    gem install transitions

    ./Gemfile
    gem "rails", "3.0.0.beta3"
    gem "transitions"<commit_msg>Updated the Quick Start Guide<commit_after># Transitions

Transitions aims to remove traditional ActiveRecord migrations and replace it with DataMapper-like automatic migrations mixed with event based data patching.

The major advantage of Transitions over migrations is that it allows Rails engines to define there own schemas which get automatically loaded in the application. The application remains in full control as it can overwrite an engines schema.

## Installation

### Using Ruby gems

Install the gem:

    #!/usr/bin/env bash
    $ gem install transitions

Add the gem to your `Gemfile`

    gem "rails", "3.0.0.beta3"
    gem "transitions"

### Using git

Add the repo to your `Gemfile`

    gem "transitions", :git => "git://github.com/fd/transitions.git"

## Quick Start Guide

Generate a `Post` model without the migration file.

    $ rails g model Post --migration=false

Create a schema file at `app/schemas/posts_schema.rb` with the following contents:

    class PostsSchema < Transitions::Schema

      table :posts do |t|
        t.string   :title
        t.text     :body

        t.datetime :published_at
        t.timestamps
      end

    end

Then transition the database to the new schema:

    $ rake db:transition
    --- Creating table posts
     +c title:string
     +c body:text
     +c published_at:datetime
     +c created_at:datetime
     +c updated_at:datetime

Now, let's make some trivial changes:

- add an index to the published_at column
- add an extra column for the tags

and here is the diff:

    --- a/app/schemas/posts_schema.rb
    +++ b/app/schemas/posts_schema.rb
    @@ -4,7 +4,9 @@ class PostsSchema < Transitions::Schema
         t.string   :title
         t.text     :body

    -    t.datetime :published_at
    +    t.string :tags
    +
    +    t.datetime :published_at, :index => true
         t.timestamps
       end

Transition the database to the updated schema:

    $ rake db:transition
    --- Constructive changes for posts
     +c tags:string
     +i published_at
{'fraction_non_alphanumeric': 0.06959847036328871, 'fraction_numerical': 0.004588910133843212, 'mean_word_length': 3.006125574272588, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7070769', 'n_tokens_mistral': 734, 'n_tokens_neox': 708, 'n_words': 300}