Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

74 lines (54 sloc) 2.055 kb

Sequel Migration Builder

Builds sequel migrations based on the differences between an abstract representation of the desired schema and a database instance.

This is quite a low-level library - it doesn't provide any functionality to write out migration files, nor does it provide a ruby DSL for defining your schema (see Schema format below).

This library is also very, very new, so there WILL be bugs.


sudo gem install sequel_migration_builder


require 'sequel/migration_builder'

desired_schema = { ... } # see below
builder =
migration_code = builder.generate_migration(desired_schema)
File.write("001_some_migration.rb", migration_code)

Schema format

The schema is an abstract representation of the tables in your database, as a hash. A sample YAML version might look like:

  primary_key: id
    engine: myisam
      columns: foo
      unique: true
    - name: id
      column_type: integer
    - name: foo
      column_type: varchar
      default: "bar"
      null: true
      size: 30


  • Sequel 3.20.0 or higher


  • Dropping tables when they are removed from the schema

  • Automigrate functionality

  • Dealing with renames in some way (even if just logging that they would be possible).

  • Changing table options with alter table

  • More database type parsers

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.


Copyright © 2010 Roland Swingler. See LICENSE for details.

Jump to Line
Something went wrong with that request. Please try again.