What is the preferred way to manage schema.rb in git?

前端 未结 8 948
醉酒成梦
醉酒成梦 2020-12-01 07:05

I don\'t want to add schema.rb to .gitignore, because I want to be able to load a new database schema from that file. However, keeping it checked

8条回答
  •  孤街浪徒
    2020-12-01 08:02

    I built a gem to solve this problem.

    It sorts columns, index names and foreign keys, removes excess whitespace and runs Rubocop for some formatting to unify the output of your schema.rb file.

    https://github.com/jakeonrails/fix-db-schema-conflicts

    After you add it to your Gemfile you just run rake db:migrate or rake db:schema:dump like normal.

提交回复
热议问题