Sha256: de48eb50e4aa303456c0daceeda5293836b4826857dcceb8f1766530031f3910

Contents?: true

Size: 1.14 KB

Versions: 16

Compression:

Stored size: 1.14 KB

Contents

class CreateBitCoreSlides < ActiveRecord::Migration
  def change
    create_table :bit_core_slides do |t|
      t.string :title, null: false
      t.text :body, null: false
      t.integer :position, null: false, default: 1
      t.integer :bit_core_slideshow_id, null: false
      t.string :type
      t.boolean :is_title_visible, null: false, default: true

      t.timestamps
    end

    reversible do |dir|
      dir.up do
        execute <<-SQL
          ALTER TABLE bit_core_slides
            ADD CONSTRAINT bit_core_slide_position UNIQUE (bit_core_slideshow_id, position)
            DEFERRABLE INITIALLY IMMEDIATE
        SQL

        execute <<-SQL
          ALTER TABLE bit_core_slides
            ADD CONSTRAINT fk_slideshows_slides
            FOREIGN KEY (bit_core_slideshow_id)
            REFERENCES bit_core_slideshows(id)
        SQL
      end

      dir.down do
        execute <<-SQL
          ALTER TABLE bit_core_slides
            DROP CONSTRAINT fk_slideshows_slides
        SQL

        execute <<-SQL
          ALTER TABLE bit_core_slides
            DROP CONSTRAINT IF EXISTS bit_core_slide_position
        SQL
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
bit_core-1.4.7 db/migrate/20140417174159_create_bit_core_slides.rb
bit_core-2.0.0.beta2 db/migrate/20140417174159_create_bit_core_slides.rb
bit_core-2.0.0.beta1 db/migrate/20140417174159_create_bit_core_slides.rb
bit_core-1.4.6 db/migrate/20140417174159_create_bit_core_slides.rb
bit_core-1.4.5 db/migrate/20140417174159_create_bit_core_slides.rb
bit_core-1.2.2 db/migrate/20140417174159_create_bit_core_slides.rb
bit_core-1.2.1 db/migrate/20140417174159_create_bit_core_slides.rb
bit_core-1.2.0 db/migrate/20140417174159_create_bit_core_slides.rb
bit_core-1.1.6 db/migrate/20140417174159_create_bit_core_slides.rb
bit_core-1.1.5 db/migrate/20140417174159_create_bit_core_slides.rb
bit_core-1.1.4 db/migrate/20140417174159_create_bit_core_slides.rb
bit_core-1.1.3 db/migrate/20140417174159_create_bit_core_slides.rb
bit_core-1.1.2 db/migrate/20140417174159_create_bit_core_slides.rb
bit_core-1.1.1 db/migrate/20140417174159_create_bit_core_slides.rb
bit_core-1.1.0 db/migrate/20140417174159_create_bit_core_slides.rb
bit_core-1.0.0 db/migrate/20140417174159_create_bit_core_slides.rb