Sha256: df83a7dac8fca0fd64055cb1d0ef154320d45e8c8278d64d93cb226261fe24fc

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

class HancockGalleryCreateGallery < ActiveRecord::Migration
  def change
    ########### c #################
    create_table :hancock_gallery_gallery_images do |t|
      t.integer :gallery_id
      t.integer :hancock_gallery_imagable_id
      t.string :hancock_gallery_imagable_type

      t.boolean :enabled, default: true, null: false

      if Hancock::Gallery.config.localize
        t.column :name_translations, 'hstore', default: {}
      else
        t.string :name, null: false
      end

      t.attachment :image
      t.timestamps
    end

    add_index :hancock_gallery_gallery_images, [:enabled]
    add_index :hancock_gallery_gallery_images, [:gallery_id]
    add_index :hancock_gallery_gallery_images, [:hancock_gallery_imagable_id, :hancock_gallery_imagable_type]



    ########### Galleries #################
    create_table :hancock_gallery_gallery do |t|
      t.boolean :enabled, default: true, null: false

      if Hancock::Gallery.config.localize
        t.column :name_translations, 'hstore', default: {}
      else
        t.string :name, null: false
      end

      t.integer :parent_id
      t.integer :lft
      t.integer :rgt
      t.integer :depth

      t.string :slug, null: false
      t.attachment :image
      t.timestamps
    end

    add_index :hancock_gallery_galleries, :slug, unique: true
    add_index :hancock_gallery_galleries, [:enabled, :lft]

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hancock_cms_gallery-1.0.2 lib/generators/hancock/gallery/migrations/templates/migration_gallery.rb
hancock_cms_gallery-1.0.0 lib/generators/hancock/gallery/migrations/templates/migration_gallery.rb