loco
loco copied to clipboard
Decoupling loco-cli from project for db related commands.
Description
Sometimes, the project is in a state, in which the project does not compile. Maybe you were to eager and implemented a function against a entity, that does not exist yet. Maybe a migration has not run yet or you've broken your project like described below.
If in such a state, running cargo loco
fails, because the main project does not compile,
making you unable to run migrations from loco-cli
.
To Reproduce
I've had this idea because I broke my project by accident:
- Create a new database.
- Forget to run the initial migrations.
- Run
cargo loco db entities
. - Et voilá! Your project is in a defunct state. Migrations and entities cannot be generated.
Expected Behavior
Since the migrations are stored in a separate project, it'd be great if we could run them from loco-cli even though the main project does not compile, without having to run migration executable manually and creating the missing entities manually.
Environment:
--
Additional Context
--
I think there is good motivation here to find a solution.
Technically we need to find out how this can be achievable with the same level of developer experience (meaning one command to rule them all)
What I'm thinking about so far is that loco migrate
would actually be aliased to a separate migration binary, which should exist in the secondary project.
But since all of this is uncharted territory (I don't think anyone built a similar framework on top of SeaORM before), we have to experiment a lot.
Did you have other specific ideas maybe?
I'll need some time to think about requirements. Once I've come up with specific ideas, I'll let you know.