How to disable db:schema:dump for migrations

后端 未结 6 804
悲&欢浪女
悲&欢浪女 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:15

    Rather than overriding the db:migrate behavior (which is obviously necessary when you're building the migration in development, but unnecessary when deploying) I would suggest creating a separate task like:

    # http://stackoverflow.com/questions/13646840/how-to-make-rake-dbmigrate-generate-schema-rb-when-using-sql-schema-format
    namespace :db do
      desc "Migrate the database, without dumping the schema.rb"
      task :deploy => :environment do
        ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
        ActiveRecord::Migrator.migrate("db/migrate/", nil)
      end
    end
    

    Then during your deployments you can simply do

    rake db:deploy
    

提交回复
热议问题