blob: 4af8dee2206e095ec82821752fef83b6ca95e2d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# frozen_string_literal: true
class AddBookStuff < ActiveRecord::Migration[4.2]
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
|