Sha256: 6f161ee0c17a9fe43f26638da297de51948b89493caecf7656c81a871173d692

Contents?: true

Size: 1.76 KB

Versions: 8

Compression:

Stored size: 1.76 KB

Contents

describe 'Ridgepole::Client#diff -> migrate', condition: [:activerecord_5] 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) { <<-EOS }
      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", using: :btree
      end
    EOS

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

    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) { <<-EOS }
      create_table "users", force: :cascade do |t|
        t.string "name", null: false
        t.index "lower((name)::text)", name: "index_users_on_lower_name", using: :btree
      end
    EOS

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

    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

8 entries across 8 versions & 1 rubygems

Version Path
ridgepole-0.6.6 spec/postgresql/migrate/migrate_drop_expression_index_spec.rb
ridgepole-0.6.6.beta3 spec/postgresql/migrate/migrate_drop_expression_index_spec.rb
ridgepole-0.6.6.beta2 spec/postgresql/migrate/migrate_drop_expression_index_spec.rb
ridgepole-0.6.6.beta spec/postgresql/migrate/migrate_drop_expression_index_spec.rb
ridgepole-0.6.5 spec/postgresql/migrate/migrate_drop_expression_index_spec.rb
ridgepole-0.6.5.beta14 spec/postgresql/migrate/migrate_drop_expression_index_spec.rb
ridgepole-0.6.5.beta13 spec/postgresql/migrate/migrate_drop_expression_index_spec.rb
ridgepole-0.6.5.beta12 spec/postgresql/migrate/migrate_drop_expression_index_spec.rb