Sha256: 8089488826376a26d3ee8873437aae79d6737ef9237a026407d294fd6c132366

Contents?: true

Size: 1.85 KB

Versions: 17

Compression:

Stored size: 1.85 KB

Contents

# frozen_string_literal: true

describe 'Ridgepole::Client#diff -> migrate' do
  context 'when create fk with ignore:true' do
    let(:actual_dsl) do
      erbh(<<-ERB)
        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", <%= i cond('>= 5.1',id: :integer) %>, force: :cascade do |t|
        end
      ERB
    end

    let(:expected_dsl) do
      erbh(actual_dsl + <<-ERB)
        add_foreign_key "child", "parent", name: "child_ibfk_1", ignore: true
      ERB
    end

    before { subject.diff(actual_dsl).migrate }
    subject { client }

    it {
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_falsey
    }
  end

  context 'when change fk with ignore:true' do
    let(:actual_dsl) do
      erbh(<<-ERB)
        create_table "parent", <%= i cond('>= 5.1',id: :integer) %>, 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: "child_ibfk_1", on_delete: :cascade
      ERB
    end

    let(:expected_dsl) do
      erbh(<<-ERB)
        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", <%= i cond('>= 5.1',id: :integer) %>, force: :cascade do |t|
        end

        add_foreign_key "child", "parent", name: "child_ibfk_1", ignore: true
      ERB
    end

    before { subject.diff(actual_dsl).migrate }

    subject { client }

    it {
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_falsey
    }
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ridgepole-0.8.13 spec/mysql/fk/migrate_ignore_fk_spec.rb
ridgepole-0.9.0.beta spec/mysql/fk/migrate_ignore_fk_spec.rb
ridgepole-0.8.12 spec/mysql/fk/migrate_ignore_fk_spec.rb
ridgepole-0.8.11 spec/mysql/fk/migrate_ignore_fk_spec.rb
ridgepole-0.8.10 spec/mysql/fk/migrate_ignore_fk_spec.rb
ridgepole-0.8.9 spec/mysql/fk/migrate_ignore_fk_spec.rb
ridgepole-0.8.8 spec/mysql/fk/migrate_ignore_fk_spec.rb
ridgepole-0.8.7 spec/mysql/fk/migrate_ignore_fk_spec.rb
ridgepole-0.8.6 spec/mysql/fk/migrate_ignore_fk_spec.rb
ridgepole-0.8.5 spec/mysql/fk/migrate_ignore_fk_spec.rb
ridgepole-0.8.4 spec/mysql/fk/migrate_ignore_fk_spec.rb
ridgepole-0.8.3 spec/mysql/fk/migrate_ignore_fk_spec.rb
ridgepole-0.8.2 spec/mysql/fk/migrate_ignore_fk_spec.rb
ridgepole-0.8.1 spec/mysql/fk/migrate_ignore_fk_spec.rb
ridgepole-0.8.0 spec/mysql/fk/migrate_ignore_fk_spec.rb
ridgepole-0.8.0.rc2 spec/mysql/fk/migrate_ignore_fk_spec.rb
ridgepole-0.7.8 spec/mysql/fk/migrate_ignore_fk_spec.rb