Sha256: 46af8bd131717cf4d0e0b8e4fda2baddf5c50cbcecc9411c8bd68a03a128a4bb

Contents?: true

Size: 1.45 KB

Versions: 18

Compression:

Stored size: 1.45 KB

Contents

if postgresql?
describe 'Ridgepole::Client#diff -> migrate' do
  context 'when change fk' do
    let(:actual_dsl) {
      <<-RUBY
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: "child_ibfk_1", on_delete: :cascade
      RUBY
    }

    let(:sorted_actual_dsl) {
      <<-RUBY
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: "child_ibfk_1", on_delete: :cascade
      RUBY
    }

    let(:expected_dsl) {
      <<-RUBY
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: "child_ibfk_1"
      RUBY
    }

    before { subject.diff(actual_dsl).migrate }

    subject { client(enable_foreigner: true) }

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
ridgepole-0.6.4.beta3 spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.4.beta2 spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.4.beta spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.3 spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.3.beta5 spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.3.beta4 spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.3.beta3 spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.3.beta2 spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.3.beta spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.2 spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.2.beta spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.1 spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.1.beta2 spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.1.beta spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.0 spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.0.beta5 spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.0.beta4 spec/postgresql/fk/migrate_change_fk_spec.rb
ridgepole-0.6.0.beta3 spec/postgresql/fk/migrate_change_fk_spec.rb