Class: TagalongMigration

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

Class Method Summary collapse

Class Method Details

.downObject



30
31
32
33
# File 'lib/generators/tagalong/migration/templates/active_record/migration.rb', line 30

def self.down
  drop_table :tagalong_tags
  drop_table :tagalong_taggings
end

.upObject



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

def self.up
  create_table :tagalong_tags do |t|
    t.string :name
    t.integer :number_of_references
    t.integer :tagger_id
    t.string :tagger_type

    t.timestamps
  end

  add_index :tagalong_tags, :tagger_id
  add_index :tagalong_tags, :tagger_type
  add_index :tagalong_tags, [:tagger_id, :tagger_type]

  create_table :tagalong_taggings do |t|
    t.integer :tagalong_tag_id
    t.integer :taggable_id
    t.string :taggable_type

    t.timestamps
  end

  add_index :tagalong_taggings, :tagalong_tag_id
  add_index :tagalong_taggings, :taggable_id
  add_index :tagalong_taggings, :taggable_type
  add_index :tagalong_taggings, [:taggable_id, :taggable_type]
end