Sha256: 4780f0a4dcc04a39047e5e67d07f392249573ad96999e0282147b328cd91cc9a

Contents?: true

Size: 705 Bytes

Versions: 16

Compression:

Stored size: 705 Bytes

Contents

class CreateBitCoreTools < ActiveRecord::Migration
  def change
    create_table :bit_core_tools do |t|
      t.string :title, null: false, unique: true
      t.integer :position, null: false, default: 0

      t.timestamps
    end

    reversible do |dir|
      dir.up do
        # make deferrable so that positions can be updated
        execute <<-SQL
          ALTER TABLE bit_core_tools
            ADD CONSTRAINT bit_core_tool_position UNIQUE (position)
            DEFERRABLE INITIALLY IMMEDIATE
        SQL
      end

      dir.down do
        execute <<-SQL
          ALTER TABLE bit_core_tools
            DROP CONSTRAINT IF EXISTS bit_core_tool_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/20140415210052_create_bit_core_tools.rb
bit_core-2.0.0.beta2 db/migrate/20140415210052_create_bit_core_tools.rb
bit_core-2.0.0.beta1 db/migrate/20140415210052_create_bit_core_tools.rb
bit_core-1.4.6 db/migrate/20140415210052_create_bit_core_tools.rb
bit_core-1.4.5 db/migrate/20140415210052_create_bit_core_tools.rb
bit_core-1.2.2 db/migrate/20140415210052_create_bit_core_tools.rb
bit_core-1.2.1 db/migrate/20140415210052_create_bit_core_tools.rb
bit_core-1.2.0 db/migrate/20140415210052_create_bit_core_tools.rb
bit_core-1.1.6 db/migrate/20140415210052_create_bit_core_tools.rb
bit_core-1.1.5 db/migrate/20140415210052_create_bit_core_tools.rb
bit_core-1.1.4 db/migrate/20140415210052_create_bit_core_tools.rb
bit_core-1.1.3 db/migrate/20140415210052_create_bit_core_tools.rb
bit_core-1.1.2 db/migrate/20140415210052_create_bit_core_tools.rb
bit_core-1.1.1 db/migrate/20140415210052_create_bit_core_tools.rb
bit_core-1.1.0 db/migrate/20140415210052_create_bit_core_tools.rb
bit_core-1.0.0 db/migrate/20140415210052_create_bit_core_tools.rb