Class: EasyTagMigration

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/easy_tag/migration/templates/migration.rb

Instance Method Summary collapse

Instance Method Details

#changeObject



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
# File 'lib/generators/easy_tag/migration/templates/migration.rb', line 3

def change
  create_table :easy_tag_tags do |t|
    t.string :name

    t.timestamps
  end

  create_table :easy_tag_tag_contexts do |t|
    t.string :name

    t.timestamps
  end

  create_table :easy_tag_taggings do |t|
    t.references :tag
    t.references :tag_context
    t.references :tagger

    # You should make sure that the column created is
    # long enough to store the required class names.
    t.references :taggable, :polymorphic => true
  
    t.timestamps
  end

  add_index :easy_tag_taggings, :tag_id
  add_index :easy_tag_taggings, :tagger_id
  add_index :easy_tag_taggings, :tag_context_id
  add_index :easy_tag_taggings, [:taggable_id, :taggable_type]
end