Sha256: 86c7f0ef6d50f8c4a57272132384d58d7904bc98746fbdde0bd1f37008b42363

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

class TestSetupMigration < ActiveRecord::Migration
  def up
    return if ActiveRecord::Base.connection.table_exists? :test_classes

    create_table :test_classes do |t|
      t.string :autogenerated_username
      t.string :other_field, null: false
    end
    add_index :test_classes, :autogenerated_username, unique: true
    add_index :test_classes, :other_field, unique: true

    create_table :scoped_test_classes do |t|
      t.string :autogenerated_username
      t.string :other_field
    end
    add_index :scoped_test_classes,
              [:autogenerated_username, :other_field],
              unique: true,
              name: :scoped_uniq_indx

    create_table :multiattribute_test_classes do |t|
      t.string :autogenerated_username
      t.string :autogenerated_password
    end
    add_index :multiattribute_test_classes,
              :autogenerated_username,
              unique: true
    add_index :multiattribute_test_classes,
              :autogenerated_password,
              unique: true
  end

  def down
    drop_table :test_classes
    drop_table :scoped_test_classes
    drop_table :multiattribute_test_classes
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unique_attributes-0.1.0 spec/config/test_setup_migration.rb