Sha256: 67a4cd2a90099f60fd3906debe7bfde30dac74f6ec8f30efb79e61bc1f03668d

Contents?: true

Size: 1.73 KB

Versions: 7

Compression:

Stored size: 1.73 KB

Contents

# frozen_string_literal: true

describe 'Ridgepole::Client#diff -> migrate' do
  subject { client }

  before do
    subject.diff(actual_dsl).migrate
  end

  context 'when drop column from table containing an expression index' do
    let(:actual_dsl) { erbh(<<-ERB) }
      create_table "users", force: :cascade do |t|
        t.string "name", null: false
        t.datetime "created_at", null: false
        t.index "lower((name)::text)", name: "index_users_on_lower_name"
      end
    ERB

    let(:expected_dsl) { erbh(<<-ERB) }
      create_table "users", force: :cascade do |t|
        t.string "name", null: false
        t.index "lower((name)::text)", name: "index_users_on_lower_name"
      end
    ERB

    specify do
      delta = subject.diff(expected_dsl)
      expect(delta).to be_differ
      expect(delta.script).to match_fuzzy('remove_column("users", "created_at")')
      expect(subject.dump).to match_fuzzy(actual_dsl)
      delta.migrate
      expect(subject.dump).to match_fuzzy(expected_dsl)
    end
  end

  context 'when drop expression index' do
    let(:actual_dsl) { erbh(<<-ERB) }
      create_table "users", force: :cascade do |t|
        t.string "name", null: false
        t.index "lower((name)::text)", name: "index_users_on_lower_name"
      end
    ERB

    let(:expected_dsl) { <<-RUBY }
      create_table "users", force: :cascade do |t|
        t.string "name", null: false
      end
    RUBY

    specify do
      delta = subject.diff(expected_dsl)
      expect(delta).to be_differ
      expect(delta.script).to match_fuzzy('remove_index("users", name: "index_users_on_lower_name")')
      expect(subject.dump).to match_fuzzy(actual_dsl)
      delta.migrate
      expect(subject.dump).to match_fuzzy(expected_dsl)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ridgepole-0.9.5 spec/postgresql/migrate/migrate_drop_expression_index_spec.rb
ridgepole-0.9.4 spec/postgresql/migrate/migrate_drop_expression_index_spec.rb
ridgepole-0.9.3 spec/postgresql/migrate/migrate_drop_expression_index_spec.rb
ridgepole-0.9.2 spec/postgresql/migrate/migrate_drop_expression_index_spec.rb
ridgepole-0.9.1 spec/postgresql/migrate/migrate_drop_expression_index_spec.rb
ridgepole-0.9.0 spec/postgresql/migrate/migrate_drop_expression_index_spec.rb
ridgepole-0.9.0.rc1 spec/postgresql/migrate/migrate_drop_expression_index_spec.rb