Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Check dumped schema before considering it complete.

  • Loading branch information...
commit 48d7857741bc073b04d42f7522426e51a7bf7eed 1 parent b2c3d13
@wisq authored
Showing with 11 additions and 1 deletion.
  1. +11 −1 lib/rails_parallel/rake.rb
View
12 lib/rails_parallel/rake.rb
@@ -223,8 +223,10 @@ def generate_schema(digest, schema)
raise 'mysqldump failed' unless $?.success?
raise 'No schema dumped' unless file.size > 0
+ check_schema(file)
+
+ file.close
File.rename(file.path, schema)
- $schema_dump_file = nil
invoke_task('db:drop', :force)
@@ -238,6 +240,14 @@ def invoke_task(name, force = false)
task.reenable if force
task.invoke
end
+
+ def check_schema(fh)
+ fh.seek(0, IO::SEEK_SET)
+ schema = fh.read
+
+ raise "No schema_migrations table found in dump" unless schema.include?("CREATE TABLE `schema_migrations`")
+ raise "Dump appears to be incomplete" unless schema.include?("\n-- Dump completed on ")
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.