gist: 14880 Download_button fork
public
Public Clone URL: git://gist.github.com/14880.git
001_person_migration.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# For details on Sequel migrations see
# http://sequel.rubyforge.org/
# http://code.google.com/p/ruby-sequel/wiki/Migrations
 
class PersonMigration < Sequel::Migration
 
  def up
    create_table :people do
      primary_key :id
      string :name
    end
  end
 
  def down
    drop_table :people
  end
 
end
 
002_note_migration.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# For details on Sequel migrations see
# http://sequel.rubyforge.org/
# http://code.google.com/p/ruby-sequel/wiki/Migrations
 
class NoteMigration < Sequel::Migration
 
  def up
    create_table :notes do
      primary_key :id
      integer :person_id
      string :body
    end
  end
 
  def down
    drop_table :notes
  end
 
end
note.rb
1
2
3
4
class Note < Sequel::Model
  many_to_one :person
end
 
person.rb
1
2
3
4
class Person < Sequel::Model
  one_to_many :notes
end
 
Text only
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(in /Users/antares/dev/experiments/merb/ticket-merb-plugins-115)
 ~ Loaded DEVELOPMENT Environment...
 ~ loading gem 'merb_sequel' ...
 ~ Connecting to the 'mpt_115' database on '' using 'sqlite' ...
 ~ Parent pid: 87389
 ~ PRAGMA table_info(`notes`)
 ~ PRAGMA table_info(`people`)
 ~ Compiling routes...
 ~ SELECT * FROM `sqlite_master` WHERE (type = 'table' AND NOT name = 'sqlite_sequence')
 ~ CREATE TABLE `schema_info` (`version` integer)
 ~ SELECT * FROM `schema_info` LIMIT 1
 ~ CREATE TABLE `people` (`id` integer PRIMARY KEY AUTOINCREMENT, `name` string)
 ~ CREATE TABLE `notes` (`id` integer PRIMARY KEY AUTOINCREMENT, `person_id` integer, `body` string)
 ~ SELECT * FROM `sqlite_master` WHERE (type = 'table' AND NOT name = 'sqlite_sequence')
 ~ SELECT * FROM `schema_info` LIMIT 1
 ~ INSERT INTO `schema_info` (`version`) VALUES (2)

Revisions