rake db:schema:dump 是否从迁移或数据库本身重新创建 schema.rb? [英] Does rake db:schema:dump recreate schema.rb from migrations or the database itself?
本文介绍了rake db:schema:dump 是否从迁移或数据库本身重新创建 schema.rb?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
会
rake db:schema:dump
从迁移或数据库本身重新创建 schema.rb
?
recreate schema.rb
from migrations or the database itself?
推荐答案
答案很简单:来自数据库.
The answer is simple: from the database.
顺便说一句 - 当你 采取查看 db:* tasks 的源代码 可以看到迁移任务在运行后调用了 schema:dump
By the way - when you take a look into the source code of db:* tasks you can see that migration tasks calls schema:dump after the run
desc "Migrate the database (options: VERSION=x, VERBOSE=false)."
task :migrate => :environment do
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
end
因此,迁移的工作方式是更改数据库并然后生成 schema.rb 文件.
So the migration works in the way that it change the database and then generate schema.rb file.
这篇关于rake db:schema:dump 是否从迁移或数据库本身重新创建 schema.rb?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文