Sha256: 9f0910f7cd569f9950a1d30112ab8be47bf59e2dbb1508849ef3b535c641160a

Contents?: true

Size: 1.4 KB

Versions: 13

Compression:

Stored size: 1.4 KB

Contents

describe 'Ridgepole::Client#diff -> migrate' do
  context 'when change fk' do
    let(:actual_dsl) {
      erbh(<<-EOS)
create_table "parent", force: :cascade do |t|
end

create_table "child", force: :cascade do |t|
  t.integer "parent_id"
end

<%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>

add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc", on_delete: :cascade
      EOS
    }

    let(:sorted_actual_dsl) {
      erbh(<<-EOS)
create_table "child", force: :cascade do |t|
  t.integer "parent_id"
end

<%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>

create_table "parent", force: :cascade do |t|
end

add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc", on_delete: :cascade
      EOS
    }

    let(:expected_dsl) {
      erbh(<<-EOS)
create_table "child", force: :cascade do |t|
  t.integer "parent_id"
end

<%= add_index "child", ["parent_id"], name: "par_id", using: :btree %>

create_table "parent", force: :cascade do |t|
end

add_foreign_key "child", "parent", name: "fk_rails_e74ce85cbc"
      EOS
    }

    before { subject.diff(actual_dsl).migrate }

    subject { client(dumb_with_default_fk_name: true) }

    it {
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_truthy
      expect(subject.dump).to match_fuzzy sorted_actual_dsl
      delta.migrate
      expect(subject.dump).to match_fuzzy expected_dsl
    }
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ridgepole-0.6.5.beta14 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta13 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta12 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta11 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta10 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta9 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta8 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta7 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta6 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta5 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta4 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta3 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta2 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb