Upgrade to Rails 2.2.0
As a side benefit, fix an (non-user-visible) bug in display_s5(). Also fixed a bug where removing orphaned pages did not expire cached summary pages.
This commit is contained in:
parent
39348c65c2
commit
7600aef48b
827 changed files with 123652 additions and 11027 deletions
57
vendor/rails/railties/lib/tasks/databases.rake
vendored
57
vendor/rails/railties/lib/tasks/databases.rake
vendored
|
@ -28,8 +28,24 @@ namespace :db do
|
|||
|
||||
def create_database(config)
|
||||
begin
|
||||
ActiveRecord::Base.establish_connection(config)
|
||||
ActiveRecord::Base.connection
|
||||
if config['adapter'] =~ /sqlite/
|
||||
if File.exist?(config['database'])
|
||||
$stderr.puts "#{config['database']} already exists"
|
||||
else
|
||||
begin
|
||||
# Create the SQLite database
|
||||
ActiveRecord::Base.establish_connection(config)
|
||||
ActiveRecord::Base.connection
|
||||
rescue
|
||||
$stderr.puts $!, *($!.backtrace)
|
||||
$stderr.puts "Couldn't create database for #{config.inspect}"
|
||||
end
|
||||
end
|
||||
return # Skip the else clause of begin/rescue
|
||||
else
|
||||
ActiveRecord::Base.establish_connection(config)
|
||||
ActiveRecord::Base.connection
|
||||
end
|
||||
rescue
|
||||
case config['adapter']
|
||||
when 'mysql'
|
||||
|
@ -52,10 +68,6 @@ namespace :db do
|
|||
$stderr.puts $!, *($!.backtrace)
|
||||
$stderr.puts "Couldn't create database for #{config.inspect}"
|
||||
end
|
||||
when 'sqlite'
|
||||
`sqlite "#{config['database']}"`
|
||||
when 'sqlite3'
|
||||
`sqlite3 "#{config['database']}"`
|
||||
end
|
||||
else
|
||||
$stderr.puts "#{config['database']} already exists"
|
||||
|
@ -101,8 +113,16 @@ namespace :db do
|
|||
end
|
||||
|
||||
namespace :migrate do
|
||||
desc 'Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x'
|
||||
task :redo => [ 'db:rollback', 'db:migrate' ]
|
||||
desc 'Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x. Target specific version with VERSION=x.'
|
||||
task :redo => :environment do
|
||||
if ENV["VERSION"]
|
||||
Rake::Task["db:migrate:down"].invoke
|
||||
Rake::Task["db:migrate:up"].invoke
|
||||
else
|
||||
Rake::Task["db:rollback"].invoke
|
||||
Rake::Task["db:migrate"].invoke
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Resets your database using your migrations for the current environment'
|
||||
task :reset => ["db:drop", "db:create", "db:migrate"]
|
||||
|
@ -141,6 +161,9 @@ namespace :db do
|
|||
when 'mysql'
|
||||
ActiveRecord::Base.establish_connection(config)
|
||||
puts ActiveRecord::Base.connection.charset
|
||||
when 'postgresql'
|
||||
ActiveRecord::Base.establish_connection(config)
|
||||
puts ActiveRecord::Base.connection.encoding
|
||||
else
|
||||
puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
|
||||
end
|
||||
|
@ -179,16 +202,19 @@ namespace :db do
|
|||
end
|
||||
|
||||
namespace :fixtures do
|
||||
desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
||||
desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures."
|
||||
task :load => :environment do
|
||||
require 'active_record/fixtures'
|
||||
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
||||
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'test', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
||||
Fixtures.create_fixtures('test/fixtures', File.basename(fixture_file, '.*'))
|
||||
ActiveRecord::Base.establish_connection(Rails.env)
|
||||
base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures')
|
||||
fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
|
||||
|
||||
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
|
||||
Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
|
||||
end
|
||||
end
|
||||
|
||||
desc "Search for a fixture given a LABEL or ID."
|
||||
desc "Search for a fixture given a LABEL or ID. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures."
|
||||
task :identify => :environment do
|
||||
require "active_record/fixtures"
|
||||
|
||||
|
@ -197,7 +223,8 @@ namespace :db do
|
|||
|
||||
puts %Q(The fixture ID for "#{label}" is #{Fixtures.identify(label)}.) if label
|
||||
|
||||
Dir["#{RAILS_ROOT}/test/fixtures/**/*.yml"].each do |file|
|
||||
base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures')
|
||||
Dir["#{base_dir}/**/*.yml"].each do |file|
|
||||
if data = YAML::load(ERB.new(IO.read(file)).result)
|
||||
data.keys.each do |key|
|
||||
key_id = Fixtures.identify(key)
|
||||
|
@ -314,7 +341,7 @@ namespace :db do
|
|||
case abcs["test"]["adapter"]
|
||||
when "mysql"
|
||||
ActiveRecord::Base.establish_connection(:test)
|
||||
ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"])
|
||||
ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"], abcs["test"])
|
||||
when "postgresql"
|
||||
ActiveRecord::Base.clear_active_connections!
|
||||
drop_database(abcs['test'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue