Rails 佣金 db:structure:load 与佣金 db:schema:load
Rails rake db:structure:load vs. rake db:schema:load
结构是否只是数据库的 sql
版本,而模式是数据库的 Rails
版本?你想什么时候加载?或者它有什么不同?
架构文件是数据库的 Rails 版本,不包含任何数据库特定的内容,如视图、触发器等。
db/schema.rb cannot express database specific items such as triggers,
sequences, stored procedures or check constraints, etc. Please note
that while custom SQL statements can be run in migrations, these
statements cannot be reconstituted by the schema dumper. If you are
using features like this, then you should set the schema format to
:sql.
http://edgeguides.rubyonrails.org/active_record_migrations.html#schema-dumping-and-you
你什么时候使用一个而不是另一个取决于你是否有你需要的特定于数据库的东西。如果您只使用基本表、索引以及主键和外键,那么您最好使用模式文件。
但在我看来,我总是使用 structure.sql
,因为我总是使用一些特定于数据库的东西。
您可以通过在 config/application.rb
文件中更改此格式来更改要使用的格式。
config.active_record.schema_format = :sql # default is :ruby
结构是否只是数据库的 sql
版本,而模式是数据库的 Rails
版本?你想什么时候加载?或者它有什么不同?
架构文件是数据库的 Rails 版本,不包含任何数据库特定的内容,如视图、触发器等。
db/schema.rb cannot express database specific items such as triggers, sequences, stored procedures or check constraints, etc. Please note that while custom SQL statements can be run in migrations, these statements cannot be reconstituted by the schema dumper. If you are using features like this, then you should set the schema format to :sql. http://edgeguides.rubyonrails.org/active_record_migrations.html#schema-dumping-and-you
你什么时候使用一个而不是另一个取决于你是否有你需要的特定于数据库的东西。如果您只使用基本表、索引以及主键和外键,那么您最好使用模式文件。
但在我看来,我总是使用 structure.sql
,因为我总是使用一些特定于数据库的东西。
您可以通过在 config/application.rb
文件中更改此格式来更改要使用的格式。
config.active_record.schema_format = :sql # default is :ruby