instiki/script/create_db

25 lines
583 B
Plaintext
Raw Normal View History

#!/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}..."
2005-08-09 04:20:28 +02:00
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