Rails: Alter migrations during early development phases

前端 未结 6 598
栀梦
栀梦 2021-02-04 22:08

During the very early phases of development in a Rails app, I prefer to modify the migrations files directly to add new columns (fields) to my tables (models) instead of piling

6条回答
  •  一个人的身影
    2021-02-04 22:40

    Cleanest solution, driven from Vijay Dev's solution is to create a rake task:

    namespace :db do
      desc "Drops, recreates and seeds the database."
      task :reload => [:drop, :create, :migrate, :seed] do
        Rake::Task['db:drop'].invoke
        Rake::Task['db:create'].invoke
        Rake::Task['db:migrate'].invoke
        Rake::Task['db:seed'].invoke
      end
    end
    

提交回复
热议问题