質問

Ubuntu, rails 4.1, capistrano 3.1

I deployed my rails app to server with Capistrano, and during this procedure, db:migration was executed and database has been build up.

However, later I created new migrations, and when I use "cap production deploy", it shows my original db misses some table (db:migration not executed on my new migrations); and when I use "cap production deploy:migrate", then capistrano will run all the migrations (including those that have already been executed before), so it report some table already exist (of course they exist before).

My question is, how can I just execute db:migrate on those newly created migrations ?

Thanks

役に立ちましたか?

解決

I think I know the answer:

It's nothing wrong with Capistrano!

During the deploy procedure, it will do things by this sequence:

1. udpate code
2. rake assets:precompile
3. rake db:migrate

Step 2 will somehow load the app, which will execute all initializer code. But here I access new db table, which should be created in #3. So this cause table missing error.

Just wonder why loading app during assets:precompile, what's the use of it? Can we don't do that?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top