Sha256: 688e5965f2434c9547da000e1d666753d2ab943fd6dfaa3106ccad73d0edb5e6

Contents?: true

Size: 1.5 KB

Versions: 11

Compression:

Stored size: 1.5 KB

Contents

describe 'Ridgepole::Client#diff -> migrate (with index)' do
  context 'when create table' 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.string  "dept_no", null: false
          t.date    "from_date", null: false
          t.date    "to_date", null: false
          t.index ["dept_no"], name: "dept_no", <%= i cond(5.0, using: :btree) %>
          t.index ["emp_no"], name: "emp_no", <%= i cond(5.0, using: :btree) %>
        end
      ERB
    end

    before { subject.diff(actual_dsl).migrate }
    subject { client(create_table_with_index: 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", :"string", {:null=>false, :limit=>255})
          t.column("from_date", :"date", {:null=>false})
          t.column("to_date", :"date", {:null=>false})
          t.index(["dept_no"], <%= {:name=>"dept_no"} + cond(5.0, using: :btree) %>)
          t.index(["emp_no"], <%= {:name=>"emp_no"} + cond(5.0, using: :btree) %>)
        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

11 entries across 11 versions & 1 rubygems

Version Path
ridgepole-0.8.0.rc1 spec/mysql/migrate/migrate_create_table_with_index_spec.rb
ridgepole-0.7.7 spec/mysql/migrate/migrate_create_table_with_index_spec.rb
ridgepole-0.7.6 spec/mysql/migrate/migrate_create_table_with_index_spec.rb
ridgepole-0.7.5 spec/mysql/migrate/migrate_create_table_with_index_spec.rb
ridgepole-0.7.5.beta3 spec/mysql/migrate/migrate_create_table_with_index_spec.rb
ridgepole-0.7.5.beta2 spec/mysql/migrate/migrate_create_table_with_index_spec.rb
ridgepole-0.7.5.beta spec/mysql/migrate/migrate_create_table_with_index_spec.rb
ridgepole-0.7.4 spec/mysql/migrate/migrate_create_table_with_index_spec.rb
ridgepole-0.7.3 spec/mysql/migrate/migrate_create_table_with_index_spec.rb
ridgepole-0.7.3.beta3 spec/mysql/migrate/migrate_create_table_with_index_spec.rb
ridgepole-0.7.3.beta2 spec/mysql/migrate/migrate_create_table_with_index_spec.rb