Sha256: 3b999f2fed90d9c81dc802d38b49f30ebdfc3ff12075c4f2ff4c11a8ae65545e

Contents?: true

Size: 1.16 KB

Versions: 16

Compression:

Stored size: 1.16 KB

Contents

class CreateImageManager < ActiveRecord::Migration[5.0]
  def change
    create_table :image_manager_files do |t|
      t.string      :name, null: false
      t.text        :description
      t.string      :copyright
      t.string      :image_file_name
      t.string      :image_content_type
      t.integer     :image_file_size
      t.datetime    :image_updated_at

      t.timestamps
    end

    # ---------------------------------------------

    create_table :image_manager_tags do |t|
      t.string      :name, null: false

      t.timestamps
    end

    add_index :image_manager_tags,  :name, unique: true

    # ---------------------------------------------

    create_join_table :image_manager_files, :image_manager_tags do |t|
      t.integer       :image_manager_file_id
      t.integer       :image_manager_tag_id
    end

    execute "ALTER TABLE image_manager_files_tags ADD PRIMARY KEY (image_manager_file_id, image_manager_tag_id)"

    add_foreign_key :image_manager_files_tags, :image_manager_files,  on_update: :cascade, on_delete: :cascade
    add_foreign_key :image_manager_files_tags, :image_manager_tags,   on_update: :cascade, on_delete: :cascade
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rails_admin_image_manager-0.1.34 db/migrate/20170626000000_create_image_manager.rb
rails_admin_image_manager-0.1.33 db/migrate/20170626000000_create_image_manager.rb
rails_admin_image_manager-0.1.31 db/migrate/20170626000000_create_image_manager.rb
rails_admin_image_manager-0.1.30 db/migrate/20170626000000_create_image_manager.rb
rails_admin_image_manager-0.1.3 db/migrate/20170626000000_create_image_manager.rb
rails_admin_image_manager-0.1.29 db/migrate/20170626000000_create_image_manager.rb
rails_admin_image_manager-0.1.28 db/migrate/20170626000000_create_image_manager.rb
rails_admin_image_manager-0.1.27 db/migrate/20170626000000_create_image_manager.rb
rails_admin_image_manager-0.1.26 db/migrate/20170626000000_create_image_manager.rb
rails_admin_image_manager-0.1.25 db/migrate/20170626000000_create_image_manager.rb
rails_admin_image_manager-0.1.24 db/migrate/20170626000000_create_image_manager.rb
rails_admin_image_manager-0.1.23 db/migrate/20170626000000_create_image_manager.rb
rails_admin_image_manager-0.1.22 db/migrate/20170626000000_create_image_manager.rb
rails_admin_image_manager-0.1.21 db/migrate/20170626000000_create_image_manager.rb
rails_admin_image_manager-0.1.20 db/migrate/20170626000000_create_image_manager.rb
rails_admin_image_manager-0.1.15 db/migrate/20170626000000_create_image_manager.rb