Class: RunMigration

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/blocks/run_migration.rb

Instance Method Summary collapse

Instance Method Details

#run_migrationsObject



9
10
11
12
13
# File 'lib/blocks/run_migration.rb', line 9

def run_migrations
  db_config = Config.load(".byld/config.yml")['storage']
  ActiveRecord::Base.establish_connection(db_config)
  ActiveRecord::MigrationContext.new("models/migrations/").migrate
end

#update_schemaObject



15
16
17
18
19
20
# File 'lib/blocks/run_migration.rb', line 15

def update_schema
  filename = "models/schema.rb"
  File.open(filename, "w:utf-8") do |file|
    ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
  end
end