Is it considered safe to manually edit schema.rb in rails

时光总嘲笑我的痴心妄想 提交于 2019-12-04 05:29:06
Kevin Bedell

It is generally considered a bad practice to edit your schema.rb file.

According to the Rails Guide on Migrations:

Migrations, mighty as they may be, are not the authoritative source for your database schema. That role falls to either db/schema.rb or an SQL file which Active Record generates by examining the database. They are not designed to be edited, they just represent the current state of the database.

schema.rb gets updated every time you run a new migration:

Note that running the db:migrate also invokes the db:schema:dump task, which will update your db/schema.rb file to match the structure of your database.

I'd recommend just spending some time to sort things out and get the schema.rb file back on track and correct up to the latest set of migrations.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!