Class: CreateBooks

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/dummy/templates/migrations/create_books.rb

Instance Method Summary collapse

Instance Method Details

#downObject



22
23
24
25
# File 'lib/generators/dummy/templates/migrations/create_books.rb', line 22

def down
  drop_table :books
  Book.drop_translation_table!
end

#upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/generators/dummy/templates/migrations/create_books.rb', line 2

def up
  create_table :books do |t|
    t.string    :title, null: false
    t.integer   :year
    t.integer   :author_id
    t.string    :genre
    t.string    :description
    t.text      :summary_html
    t.boolean   :active
    t.datetime  :published_at
    t.decimal   :price, precision: 8, scale: 2
    t.integer   :stars
    t.string    :cover_image_uid

    t.timestamps(null: false)
  end

  add_index :books, :author_id
end