aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-12-19 12:15:27 +0100
committerYves Senn <yves.senn@gmail.com>2014-12-19 12:15:27 +0100
commit10e989b76df1a833f9da22598c1a368777374a01 (patch)
tree15915fa7c404ab01fefa67652ee16905ea8533fd /railties/test/application
parent111f2f442214d0212a76484d29bf6dab1aca0507 (diff)
parentbe1e0241f012f1151d2448b10e14b8b2eda26b84 (diff)
downloadrails-10e989b76df1a833f9da22598c1a368777374a01.tar.gz
rails-10e989b76df1a833f9da22598c1a368777374a01.tar.bz2
rails-10e989b76df1a833f9da22598c1a368777374a01.zip
Merge pull request #18082 from rails/17945_purge_in_test_only
`db:schema:load` and `db:structure:load` do not purge the database
Diffstat (limited to 'railties/test/application')
-rw-r--r--railties/test/application/rake/dbs_test.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/railties/test/application/rake/dbs_test.rb b/railties/test/application/rake/dbs_test.rb
index 0a5873bcbf..c414732f92 100644
--- a/railties/test/application/rake/dbs_test.rb
+++ b/railties/test/application/rake/dbs_test.rb
@@ -156,6 +156,31 @@ module ApplicationTests
end
end
+ test 'db:schema:load and db:structure:load do not purge the existing database' do
+ Dir.chdir(app_path) do
+ `bin/rails runner 'ActiveRecord::Base.connection.create_table(:posts) {|t| t.string :title }'`
+
+ app_file 'db/schema.rb', <<-RUBY
+ ActiveRecord::Schema.define(version: 20140423102712) do
+ create_table(:comments) {}
+ end
+ RUBY
+
+ list_tables = lambda { `bin/rails runner 'p ActiveRecord::Base.connection.tables'`.strip }
+
+ assert_equal '["posts"]', list_tables[]
+ `bin/rake db:schema:load`
+ assert_equal '["posts", "comments", "schema_migrations"]', list_tables[]
+
+ app_file 'db/structure.sql', <<-SQL
+ CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255));
+ SQL
+
+ `bin/rake db:structure:load`
+ assert_equal '["posts", "comments", "schema_migrations", "users"]', list_tables[]
+ end
+ end
+
def db_test_load_structure
Dir.chdir(app_path) do
`rails generate model book title:string;