Module: MigrationHelpers::Items::AttachmentStructure

Defined in:
lib/migrate/items/attachment_structure.rb

Instance Method Summary collapse

Instance Method Details

#create_table_lesli_item_attachments_10(resources) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/migrate/items/attachment_structure.rb', line 36

def create_table_lesli_item_attachments_10(resources)

    table_name, foreign_key = table_name_for_item(resources, :attachments)

    create_table table_name do |t|
        t.string :name
        t.string :category
        t.decimal :size_mb

        t.string :attachment
        t.string :attachment_remote # like S3
        t.string :attachment_public
        
        t.boolean  :public
        t.string   :public_url
        t.datetime :public_url_expiration_at

        t.datetime :deleted_at, index: true
        t.timestamps
    end

    add_reference(table_name, :user, foreign_key: { to_table: :lesli_users })
    add_reference(table_name, foreign_key, foreign_key: { to_table: resources })
end