basyura's blog

あしたになったらほんきだす。

migrate

実行されないと思ったらファイル名に規則がある

The Migrator module performs migrations based on migration files in a specified directory. The migration files should be named using the following pattern (in similar fashion to ActiveRecord migrations):
version_title.rb

Module Sequel::Migrator

ソース

class CreateUsers < Sequel::Migration
  def up
    create_table :users do
      primary_key :id
      String  :screen_name
      String  :uid ,:unique => true
      String  :name
  	end
    add_index :users, :screen_name
  end
end

実行する

require 'sequel'
require 'sequel/extensions/migration'
DB = Sequel.sqlite(dbpath)
Sequel::Migrator.apply(DB, './db/migrate')