Sha256: e7856a4f16cf24bc5a5c17c8075eaa63a2abea309311fd4508581ca22ad83c36

Contents?: true

Size: 1.57 KB

Versions: 13

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"
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", <%= i limit(4) %>
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", <%= i limit(4) %>
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

      # XXX:
      if condition(:activerecord_5)
        ActiveRecord::Base.connection.send(:create_table_info_cache).clear
      end

      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/mysql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta13 spec/mysql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta12 spec/mysql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta11 spec/mysql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta10 spec/mysql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta9 spec/mysql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta8 spec/mysql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta7 spec/mysql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta6 spec/mysql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta5 spec/mysql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta4 spec/mysql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta3 spec/mysql/~default_name_fk/migrate_change_fk_spec.rb
ridgepole-0.6.5.beta2 spec/mysql/~default_name_fk/migrate_change_fk_spec.rb