$files = Dir["#{Rails.root}/db/migrate/tables/*.rb"] $files.each do |file| require file end class MigracionGeneral < ActiveRecord::Migration[5.1] def self.tables general_tables end def self.general_tables @tables = [] $files.each do |file| require file table = "#{file.split("/").last.gsub('.rb','').titleize.delete(' ')}" next if table == 'Base' @tables.push(eval("Tables::#{table}")) end return @tables end def up run_migrations end def down raise ActiveRecord::IrreversibleMigration, 'Error' end private def run_migrations create_tables end def create_tables self.class.tables.each do |table| table.create(self) end end end