Sha256: fd50e21a6aba3b5b786053154f3d3c100f77a337602d299d48c0c1e8d913e7b5

Contents?: true

Size: 1.66 KB

Versions: 8

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

describe 'Ridgepole::Client#diff -> migrate' do
  context 'when change mysql table options' do
    let(:actual_dsl) do
      erbh(<<-ERB)
        create_table "employees", primary_key: "emp_no", force: :cascade, <%= i cond(">= 6.1", { charset: "utf8", options: "ENGINE=MyISAM" }, { options: "ENGINE=MyISAM DEFAULT CHARSET=utf8" }) %> do |t|
          t.date   "birth_date", null: false
          t.string "first_name", limit: 14, null: false
          t.string "last_name", limit: 16, null: false
          t.string "gender", limit: 1, null: false
          t.date   "hire_date", null: false
        end
      ERB
    end

    let(:expected_dsl) do
      erbh(<<-ERB)
        create_table "employees", primary_key: "emp_no", force: :cascade, <%= i cond(">= 6.1", { charset: "ascii" }, { options: "ENGINE=InnoDB DEFAULT CHARSET=ascii" }) %> do |t|
          t.date   "birth_date", null: false
          t.string "first_name", limit: 14, null: false, <%= i cond('>= 5.2', collation: "utf8_general_ci") %>
          t.string "last_name", limit: 16, null: false, <%= i cond('>= 5.2', collation: "utf8_general_ci") %>
          t.string "gender", limit: 1, null: false, <%= i cond('>= 5.2', collation: "utf8_general_ci") %>
          t.date   "hire_date", null: false
        end
      ERB
    end

    before { subject.diff(actual_dsl).migrate }
    subject { client(dump_without_table_options: false, mysql_change_table_options: true) }

    it {
      delta = subject.diff(expected_dsl)
      expect(delta.differ?).to be_truthy
      expect(subject.dump).to match_ruby actual_dsl
      delta.migrate
      expect(subject.dump).to match_ruby expected_dsl
    }
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ridgepole-0.9.5 spec/mysql/_migrate/migrate_change_table_option_spec.rb
ridgepole-0.9.4 spec/mysql/_migrate/migrate_change_table_option_spec.rb
ridgepole-0.9.3 spec/mysql/_migrate/migrate_change_table_option_spec.rb
ridgepole-0.9.2 spec/mysql/_migrate/migrate_change_table_option_spec.rb
ridgepole-0.9.1 spec/mysql/_migrate/migrate_change_table_option_spec.rb
ridgepole-0.9.0 spec/mysql/_migrate/migrate_change_table_option_spec.rb
ridgepole-0.9.0.rc1 spec/mysql/_migrate/migrate_change_table_option_spec.rb
ridgepole-0.9.0.beta spec/mysql/_migrate/migrate_change_table_option_spec.rb