What is db/development_structure.sql in a rails project?

后端 未结 4 965
無奈伤痛
無奈伤痛 2020-12-29 06:33

There is a development_structure.sql inside my /db folder of my rails application (rails 2.3.4, ruby 1.8.7) and I am not sure exactly what it does.

4条回答
  •  滥情空心
    2020-12-29 07:05

    You should not add it to your git repository.

    It is a file created automatically by rails when you run migrations with your database.yml configured to connect against a mysql database. You can view it as an alternative to schema.rb

    I believe you can force rails to create it by adding in your environment.rb:

    config.active_record.schema_format = :sql
    

    When present this file is used for example by:

    rake db:test:clone_structure
    

    Edit

    Relevant section in Ruby On Rails Guides. http://guides.rubyonrails.org/migrations.html#schema-dumping-and-you

    They recommend to check it into source control on the wiki.

    I personally like to keep it out of it. I like to be able to run all migrations very quickly. It is for me a good sign. If migrations become slow I feel like I am not in total control of my environment anymore. Slowness in migrations generally means I have a lot of data in my development database which I feel wrong.

    However, It seems to be a matter of personal taste nowadays. Follow your instincts on this one.

提交回复
热议问题