Sha256: 74e0339714315ba9a21ceaed4c83be278533de286b0c540bab3f46b515ecf8d4

Contents?: true

Size: 1.51 KB

Versions: 7

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true

describe 'Ridgepole::Client#diff -> migrate (with index)' do
  context 'when create table with auto increment column' do
    let(:actual_dsl) { '' }

    let(:expected_dsl) do
      erbh(<<-ERB)
        create_table "dept_emp", primary_key: ["emp_no", "dept_no"], force: :cascade do |t|
          t.integer "emp_no", null: false
          t.integer "dept_no", null: false, auto_increment: true
          t.date    "from_date", null: false
          t.date    "to_date", null: false
          t.index ["dept_no"], name: "dept_no"
          t.index ["emp_no"], name: "emp_no"
        end
      ERB
    end

    before { subject.diff(actual_dsl).migrate }
    subject { client(create_table_with_index: true, mysql_dump_auto_increment: true) }

    it {
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_truthy

      expect(delta.script).to match_fuzzy erbh(<<-ERB)
        create_table("dept_emp", **{:primary_key=>["emp_no", "dept_no"]}) do |t|
          t.column("emp_no", :"integer", **{:null=>false, :limit=>4})
          t.column("dept_no", :"integer", **{:null=>false, :auto_increment=>true, :limit=>4})
          t.column("from_date", :"date", **{:null=>false})
          t.column("to_date", :"date", **{:null=>false})
          t.index(["dept_no"], **{:name=>"dept_no"})
          t.index(["emp_no"], **{:name=>"emp_no"})
        end
      ERB

      expect(subject.dump).to match_ruby actual_dsl
      delta.migrate
      expect(subject.dump).to match_ruby expected_dsl
    }
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ridgepole-0.9.5 spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb
ridgepole-0.9.4 spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb
ridgepole-0.9.3 spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb
ridgepole-0.9.2 spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb
ridgepole-0.9.1 spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb
ridgepole-0.9.0 spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb
ridgepole-0.9.0.rc1 spec/mysql/~dump_auto_increment/migrate_create_table_with_index_spec.rb