Some infrastructure for AR and accompanying unit tests

This commit is contained in:
Alexey Verkhovsky 2005-08-02 08:56:09 +00:00
parent 6d8190c096
commit 1b8baa3d03
18 changed files with 155 additions and 187 deletions

24
script/create_db Normal file
View file

@ -0,0 +1,24 @@
#!/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