Method: Sequent::Migrations::Executor#set_table_names_to_new_version

Defined in:
lib/sequent/migrations/executor.rb

#set_table_names_to_new_version(plan) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/sequent/migrations/executor.rb', line 72

def set_table_names_to_new_version(plan)
  plan.replay_tables.each do |migration|
    table = migration.record_class
    next if table.table_name.end_with?("_#{migration.version}")

    table.table_name = "#{table.table_name}_#{migration.version}"
    table.reset_column_information
    unless table.table_exists?
      fail MigrationError,
           "Table #{table.table_name} does not exist. Did you run ViewSchema.migrate_online first?"
    end
  end
end