loco icon indicating copy to clipboard operation
loco copied to clipboard

Decoupling loco-cli from project for db related commands.

Open HiImJulien opened this issue 1 year ago • 2 comments

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:

  1. Create a new database.
  2. Forget to run the initial migrations.
  3. Run cargo loco db entities.
  4. 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

--

HiImJulien avatar Jan 25 '24 17:01 HiImJulien

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?

jondot avatar Jan 29 '24 07:01 jondot

I'll need some time to think about requirements. Once I've come up with specific ideas, I'll let you know.

HiImJulien avatar Feb 01 '24 10:02 HiImJulien