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
33
34
35
36
37
38
|
# File 'lib/tagutils/categories/schema.rb', line 7
def up
ActiveRecord::Schema.define do
create_table :categories do |t|
t.string :key, null: false
t.string :slug, null: false
t.string :name, null: false
t.references :parent
t.timestamps
end
add_index :categories, :key, unique: true
create_table :categorizations do |t|
t.references :category, null: false, index: false t.references :categorizable, null: false, index: false, polymorphic: true
t.timestamps
end
add_index :categorizations, :category_id, name: 'categorizations_cats_idx'
add_index :categorizations, [:categorizable_id, :categorizable_type], name: 'categorizations_idx'
add_index :categorizations, [:categorizable_id, :categorizable_type, :category_id], unique: true, name: 'categorizations_unique_idx'
end end
|