2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/generators/active_content/templates/upload.rb', line 2
def change
create_table :uploads do |t|
t.string :type
t.string :file, null: false
t.string :name, null: false
t.text :description
t.string :media_type
t.string :sub_type
t.timestamps
end
create_table :attachments do |t|
t.string :field
t.references :upload
t.references :attachable, null: false, polymorphic: true, index: false
t.timestamps
end
add_index :attachments, [:attachable_id, :attachable_type, :upload_id, :field], unique: true, name: :index_attachments_on_attachable_attribute
end
|