What does :force => true mean in the schema file

后端 未结 2 1829
無奈伤痛
無奈伤痛 2021-02-07 04:03

If you look in db/schema.rb you will see something like:

create_table \"users\", :force => true do |t|

What does the :force => true

相关标签:
2条回答
  • 2021-02-07 04:50

    From the Rails docs:

    :force

    Set to true to drop the table before creating it. Defaults to false.

    Basically, this helps ensure database integrity. If you're manually tooling around with your migrations, it's helpful to ensure that you're creating new tables from a clean slate, rather than risking naming conflicts that stem from tables that have been created on a one-off basis.

    0 讨论(0)
  • 2021-02-07 05:00

    This simply drops the table before creation. Check the docs for more info here: ActiveRecord::ConnectionAdapters::SchemaStatements

    0 讨论(0)
提交回复
热议问题