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

后端 未结 2 1826
無奈伤痛
無奈伤痛 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.

提交回复
热议问题