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
29
|
# File 'lib/generators/tagtical/migration/templates/active_record/migration.rb', line 2
def self.up
create_table :tags do |t|
t.string :value
t.string :type, :limit => 100
end
add_index :tags, [:type, :value], :unique => true
add_index :tags, :value
create_table :taggings do |t|
t.float :relevance
t.references :tag
t.references :taggable, :polymorphic => true, :limit => 100
if Tagtical.config.polymorphic_tagger?
t.references :tagger, :polymorphic => true, :limit => 100
else
t.integer :tagger_id
end
t.datetime :created_at
end
add_index :taggings, :tag_id
add_index :taggings, [:taggable_id, :taggable_type]
add_index :taggings, Tagtical.config.polymorphic_tagger? ? [:tagger_id, :tagger_type] : [:tagger_id]
end
|