@@ -692,6 +692,28 @@ class TwoMigration < ActiveRecord::Migration::Current
692
692
db_up_and_down "02" , "animals"
693
693
end
694
694
695
+ test "db:migrate:down:namespace and db:migrate:up:namespace dumps schema only for specific database" do
696
+ require "#{ app_path } /config/environment"
697
+
698
+ app_file "db/migrate/01_one_migration.rb" , <<-MIGRATION
699
+ class OneMigration < ActiveRecord::Migration::Current
700
+ end
701
+ MIGRATION
702
+
703
+ app_file "db/animals_migrate/02_two_migration.rb" , <<-MIGRATION
704
+ class TwoMigration < ActiveRecord::Migration::Current
705
+ end
706
+ MIGRATION
707
+
708
+ Dir . chdir ( app_path ) do
709
+ rails ( "db:migrate:up:primary" , "VERSION=01" )
710
+ rails ( "db:migrate:down:primary" , "VERSION=01" )
711
+
712
+ assert File . exist? ( "db/schema.rb" ) , "should dump schema for primary database"
713
+ assert_not File . exist? ( "db/animals_schema.rb" ) , "should not dump schema for animals database"
714
+ end
715
+ end
716
+
695
717
test "db:migrate:redo raises in a multi-db application" do
696
718
require "#{ app_path } /config/environment"
697
719
db_migrate_redo
@@ -742,6 +764,20 @@ class TwoMigration < ActiveRecord::Migration::Current
742
764
db_migrate_and_rollback "animals"
743
765
end
744
766
767
+ test "db:rollback:namespace dumps schema only for specific database" do
768
+ Dir . chdir ( app_path ) do
769
+ rails "generate" , "model" , "book" , "title:string"
770
+ rails "generate" , "model" , "dog" , "name:string" , "--database animals"
771
+ rails "db:migrate"
772
+ File . delete ( "db/animals_schema.rb" )
773
+
774
+ rails "db:rollback:primary"
775
+
776
+ assert File . exist? ( "db/schema.rb" ) , "should dump schema for primary database"
777
+ assert_not File . exist? ( "db/animals_schema.rb" ) , "should not dump schema for animals database"
778
+ end
779
+ end
780
+
745
781
test "db:migrate:status works on all databases" do
746
782
require "#{ app_path } /config/environment"
747
783
db_migrate_and_migrate_status
0 commit comments