Sha256: 0d503b7646004eb59c70c5b4e9a3dfbddcbb0fb08376fac5addff0212760af12

Contents?: true

Size: 1.57 KB

Versions: 32

Compression:

Stored size: 1.57 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"
          t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
        end

        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"
          t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
        end

        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"
          t.index ["parent_id"], name: "par_id", <%= i cond(5.0, using: :btree) %>
        end

        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(dump_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

32 entries across 32 versions & 1 rubygems

Version Path
ridgepole-0.7.1 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.1.beta5 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.1.beta4 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.1.beta3 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.1.beta2 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.1.beta spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.0 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.0.rc1 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.0.beta22 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.0.beta21 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.0.beta20 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.0.beta19 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.0.beta18 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.0.beta17 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.0.beta16 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.0.beta15 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.0.beta14 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.0.beta13 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.0.beta12 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.7.0.beta11 spec/postgresql/~default_name_fk/migrate_change_fk_spec.rb