Class: Yinx::SQL::Tables

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/yinx_sql.rb

Instance Method Summary collapse

Instance Method Details

#downObject



40
41
42
43
44
# File 'lib/yinx_sql.rb', line 40

def down
  [:notes_tags, :notes, :tags, :batches].each do |t|
    drop_table t
  end
end

#upObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/yinx_sql.rb', line 15

def up
  create_table :batches do |t|
    t.timestamps
  end

  create_table :tags do |t|
    t.string :name
    t.belongs_to :batch
  end

  create_table :notes do |t|
    t.string :title
    t.string :book
    t.string :stack
    t.integer :content_length
    t.timestamps
    t.belongs_to :batch
  end

  create_table :notes_tags do |t|
    t.belongs_to :note, index: true
    t.belongs_to :tag, index: true
  end
end