diff options
Diffstat (limited to 'db/migrate/20120417221951_add_book_stuff.rb')
-rw-r--r-- | db/migrate/20120417221951_add_book_stuff.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/db/migrate/20120417221951_add_book_stuff.rb b/db/migrate/20120417221951_add_book_stuff.rb new file mode 100644 index 00000000..001c1e94 --- /dev/null +++ b/db/migrate/20120417221951_add_book_stuff.rb @@ -0,0 +1,33 @@ +class AddBookStuff < ActiveRecord::Migration + def up + create_table :books do |t| + t.string :code + t.timestamps + end + add_index :books, [:code] + + create_table :chapters do |t| + t.string :title + t.belongs_to :book + t.timestamps + end + add_index :chapters, [:book_id] + + create_table :sections do |t| + t.string :title + t.string :slug + t.text :plain + t.text :html + t.belongs_to :chapter + t.timestamps + end + add_index :sections, [:slug] + add_index :sections, [:chapter_id] + end + + def down + drop_table :books + drop_table :chapters + drop_table :sections + end +end |