How to disable db:schema:dump for migrations

后端 未结 6 827
悲&欢浪女
悲&欢浪女 2020-12-09 03:57

I dont want Rails 3 to generate my schema every time I do migration. How to properly disable it?

Thanks

6条回答
  •  长情又很酷
    2020-12-09 04:22

    I've tested the following - it works:

    You could modify the file "databases.rake" inside of the Rails gem's lib/tasks folder on your server(s). Comment out lines with the following code:

    Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
    

    By default on Ubuntu (and Ubuntu server) it is here: /var/lib/gems/1.8/gems/rails-x.x.x/lib/tasks/databases.rake.

    Tested with Rails 2.3.11, but I'm pretty sure it'll work with Rails 3.x.x too.

    Another possible solution (didn't test):

    You wouldn't have to modify Rails files, just your application.

    A rails plugin called "override_rake_task" could be used to override Rake task "db:schema:dump" which is defined inside if Rails gem.

    Apparently if you are not using this plugin and if you define a task in your rails application with the same name, rake would execute both tasks: the default and yours.

提交回复
热议问题