Reputation: 617
I understand that every slot has its own configuration, but what about db migrations? How do they apply? Let's say I deploy to staging with migrations, so staging db gets updated. How does production db gets updated? And how do I access the variables in my code?
Upvotes: 2
Views: 2120
Reputation: 33
the problem is the autodeploy take more about 3 minutes but the db migration is done in about 30 secondes
Upvotes: 2
Reputation: 367
When you update the staging slot, whichever DB is connected to that slot will get updated.
Let me describe two scenarios -
Production Slot and Staging slot uses same DB: In this case, if you update the code and perform an upgrade to the staging slot, the production DB will receive all the db migrations as it is also bound to the staging slot. This might not be an ideal approach.
Production Slot and Staging Slot uses separate DB: Here, if you run the update on staging slot, the db migration will be performed on the db connected to that slot and production db will remain unchanged.
Now, the 1st scenario would not be a good idea as you are making changes directly to your production db. But you are getting a completely updated db. In the 2nd scenario, it is safe but your latest data might not be consistent.
The best idea would be to follow the 2nd scenario for testing. And when the test is complete -
Upvotes: 2