Class: CreateTags

Inherits:
Sequel::Migration
  • Object
show all
Defined in:
lib/sequel_taggable/migration.rb

Instance Method Summary collapse

Instance Method Details

#downObject



20
21
22
23
# File 'lib/sequel_taggable/migration.rb', line 20

def down
  drop_table :tags
  drop_table :taggings
end

#upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/sequel_taggable/migration.rb', line 2

def up
  create_table :tags do
    primary_key :id, :integer, :auto_increment => true
    varchar :name, :null => false
  end
  
  create_table :taggings do
    primary_key :id, :integer, :auto_increment => true
    integer :tag_id, :null => false
    integer :taggable_id, :null => false
    varchar :taggable_type, :null => false
    #varchar :tag_context, :null => false
    
    #datetime :created_at #TODO decide on using is_timestamped plugin to autofill this
    index [:tag_id, :taggable_id, :taggable_type]
  end
end