Sha256: 7c7f3e9f615fa3185b885f754a9c8a5666bb70708bf01e0f1c4a93b0b7cc40b6

Contents?: true

Size: 1.49 KB

Versions: 17

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

describe 'Ridgepole::Client#diff -> migrate' do
  context 'when drop column and unique index' do
    let(:actual_dsl) do
      erbh(<<-ERB)
        create_table "employees", primary_key: "emp_no", force: :cascade do |t|
          t.string "first_name", limit: 14, null: false
          t.string "last_name", limit: 16, null: false
          t.index ["first_name", "last_name"], name: "first_name_last_name", unique: true, <%= i cond(5.0, using: :btree) %>
        end
      ERB
    end

    let(:expected_dsl) do
      erbh(<<-ERB)
        create_table "employees", primary_key: "emp_no", force: :cascade do |t|
          t.string "first_name", limit: 14, null: false
        end
      ERB
    end

    before do
      subject.diff(actual_dsl).migrate
      ActiveRecord::Base.connection.execute(<<-'SQL'
        insert into
          employees (first_name, last_name)
        values
          ('Taro', 'Yamada'), ('Taro', 'Sato')
        ;
      SQL
                                           )
    end
    subject { client }

    it {
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_truthy
      expect(subject.dump).to match_ruby actual_dsl
      delta.migrate
      expect(subject.dump).to match_ruby expected_dsl
    }

    it {
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_truthy
      expect(subject.dump).to match_ruby actual_dsl
      delta.migrate(noop: true)
      expect(subject.dump).to match_ruby actual_dsl
    }
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ridgepole-0.8.13 spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
ridgepole-0.9.0.beta spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
ridgepole-0.8.12 spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
ridgepole-0.8.11 spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
ridgepole-0.8.10 spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
ridgepole-0.8.9 spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
ridgepole-0.8.8 spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
ridgepole-0.8.7 spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
ridgepole-0.8.6 spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
ridgepole-0.8.5 spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
ridgepole-0.8.4 spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
ridgepole-0.8.3 spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
ridgepole-0.8.2 spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
ridgepole-0.8.1 spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
ridgepole-0.8.0 spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
ridgepole-0.8.0.rc2 spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb
ridgepole-0.7.8 spec/mysql/migrate/migrate_drop_column_and_unique_index_spec.rb