如何处理使用相同数据库的两个单独的laravel项目的迁移?

Our setup is this:

  1. We have and API that feeds an iOS and an Android app
  2. We have an Admin API that feeds an Admin web app

I'm developing the Admin, my colleague is developing the app API.

They both use the same database, and most of the same tables. Merging them into a single project is not an option as we will deploy to Elastic Beanstalk and the Admin doesn't need to scale, since it will be used by a small number of people.

The issue we ran into is handling migrations, and we've arrived to the following conclusions:

  • We can't both have our own migrations in our projects, as the versions would not add up
  • If we keep migrations on only one of the projects (we both have access to both projects), the project without migrations can't be redeployed without redeploying the other one
  • If we make a 3rd project that only has migrations, we are hosting an application that essentially doesn't do anything

While I can think of hacky ways of fixing this issue, we're looking for a best practices approach.

I would recommend the option of creating the third project that only has migrations. That way, you keep all the migrations in one place and avoid problems of inconsistency, and you decouple the migrations from the deployment of either app. The fact that the app doesn't "do" anything shouldn't matter; you don't need to deploy an extra app, just run the migrations from your deployment server. You don't actually have to create a whole Laravel project just for your migrations; it's fairly simple to use Eloquent outside of Laravel. This article gives an example of using the Eloquent query builder to run migrations outside of Laravel. You could also use a lightweight migrations tool like Phinx, which offers a similar feature set to Laravel's built-in migrations but with minimal dependencies.