Permalink
Browse files

Fix #4722. Fix a problem of rake db:setup task when schame format is sql

  • Loading branch information...
1 parent d11ea98 commit 15c0968baf23beda3b6444a5328731f07c095dd8 @kennyj committed Jun 16, 2012
Showing with 17 additions and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/railties/databases.rake
  2. +16 −0 railties/test/application/rake_test.rb
@@ -301,7 +301,7 @@ db_namespace = namespace :db do
end
desc 'Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first)'
- task :setup => ['db:schema:load_if_ruby', 'db:structure:load_if_sql', :seed]
+ task :setup => ['environment', 'load_config', 'db:schema:load_if_ruby', 'db:structure:load_if_sql', :seed]
desc 'Load the seed data from db/seeds.rb'
task :seed do
@@ -164,6 +164,22 @@ def test_rake_dump_structure_should_be_called_twice_when_migrate_redo
assert_no_match(/^\*\* Invoke db:structure:dump\s+$/, output)
end
+ def test_rake_db_setup_when_using_sql_format
+ add_to_config "config.active_record.schema_format = :sql"
+
+ Dir.chdir(app_path) do
+ `rails generate model product name:string;
+ rake db:migrate;
+ rake db:drop:all 2>&1`
+
+ msg = `rake db:setup 2>&1`
+
+ assert $?.success?, msg
+ assert_no_match(/schema\.rb doesn't exist yet/, msg)
+ assert_equal "products", `rails r "puts Product.table_name"`.strip
+ end
+ end
+
def test_rake_dump_schema_cache
Dir.chdir(app_path) do
`rails generate model post title:string;

0 comments on commit 15c0968

Please sign in to comment.