departurerb / departure

Percona's pt-online-schema-change runner for ActiveRecord migrations.
Other
141 stars 53 forks source link

Check for pt-osc presence before running #8

Open sauloperez opened 7 years ago

sauloperez commented 7 years ago

There's an edge case concerning create table and adding and index.

When you run a create table migration that includes an index creation from a machine that doesn't have percona-toolkit installed, the table will be created but the index will not, as the former doesn't go through pt-online-schema-change.

We should check it and raise a PerconaMigrator::CommandNotFoundError accordingly, before running a CREATE TABLE.

This also applies to any other DDL statements that don't go through pt-online-schema-change.

jamesmacwilliam commented 6 years ago

@sauloperez is this still an issue? When attempting to recreate, I tried the following:

create new migration:

-class CreateTableFoo < ActiveRecord::Migration[5.1]
    def change
      create_table :table_foos do |t|
        t.string :desc
        t.index :desc
      end
    end
  end

insert logging to departure/runner.rb

received the following sql:

CREATE TABLE `table_foos` (`id` bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, `desc` varchar(255),  INDEX `index_table_foos_on_desc`  (`desc`)) ENGIN
E=InnoDB

because there is no alter statement, the check for alter_statement? is not tripped and the regular sql runner is used.