24 lines
583 B
Ruby
24 lines
583 B
Ruby
#!/usr/bin/env ruby
|
|
|
|
APP_ROOT = File.expand_path(File.dirname(__FILE__)) + '/../'
|
|
|
|
require APP_ROOT + 'config/environment'
|
|
require 'db_structure'
|
|
|
|
config = ActiveRecord::Base.configurations
|
|
|
|
['production', 'test', 'development'].each do |target|
|
|
begin
|
|
ENV['RAILS_ENV'] = target
|
|
load APP_ROOT + 'config/environment.rb'
|
|
puts "Creating tables for #{target}..."
|
|
|
|
db_structure(config[target]['adapter']).split(/\s*;\s*/).each do |sql|
|
|
ActiveRecord::Base.connection.execute(sql)
|
|
end
|
|
|
|
puts "done."
|
|
rescue => e
|
|
puts "failed: " + e.inspect
|
|
end
|
|
end
|