Git Product home page Git Product logo

Comments (10)

B4nan avatar B4nan commented on June 1, 2024 1

I don't think we need --fake, that feels weird to me. But we can have a command to log/unlog a single migration by name, that feels quite handy and is very easy to do.

edit: but the question is where this should be available, I am not so sure I like to add a flag to the up/down commands, maybe it will be better to have separate log/unlog commands next to them

if this is implemented in Umzug instead of in MikroORM

In fact, umzug is not adding much value here, and could be easily removed, most of the stuff that @mikro-orm/migrations are doing is implemented on top of umzug, replacing most of what it does with custom implementations to allow different driver storages and whatnot.

from mikro-orm.

B4nan avatar B4nan commented on June 1, 2024 1

No, log and unlog are umzug names to add/remove lines from the migrations table, it has nothing to do with logging as in printing stuff to console.

from mikro-orm.

boenrobot avatar boenrobot commented on June 1, 2024 1

But we can have a command to log/unlog a single migration by name, that feels quite handy and is very easy to do.

edit: but the question is where this should be available, I am not so sure I like to add a flag to the up/down commands, maybe it will be better to have separate log/unlog commands next to them

I guess the real question in this case is "do we want to enable log/unlog of multiple migrations at once, with the same rules as up/down?". I will admit that in practice, most people (myself included) would log/unlog one migration at a time, so that would be fine...

Though then again, being able to log/unlog multiple at once may also come in handy in more exotic setups... and in that case, I would expect all migration names to be in the sequence that they would be logged/unlogged. Combined with a "--dry-run" like option to see the migrations that are to be migrated, but not migrate them, one could implement log/unlog that behaves like up/down with a --fake flag, if they really need to.

from mikro-orm.

boenrobot avatar boenrobot commented on June 1, 2024 1

The scenario I am trying to cover is : Lets say I modified some columns to a table externally Later on I wrote a migration to cover the change. Since the change was already applied, I wanted the orm to be able to track this as well(which is why adding it to the migration table without actually running it) .

FWIW, at work, I get into this exact scenario... usually when testing if an index improves the situation on a page with a slow query, and then if it does, it makes sense to keep it.

Plus... the other common scenario is when migration works perfectly fine on staging, but on production, due to the sheer amount of data, and the fact that the app remains online during migration... the migration takes too long while locking up everything, forcing us to interrupt the migration, and maybe find a different way to migrate. How exactly we continue after that depends on a case by case basis, but it often involves an entirely different set of queries that are far less optimal (in the sense that the migration takes longer than it would if we were just to bring the app down), but less locking, and sometimes involves "one off" scripts.

from mikro-orm.

ashleyww93 avatar ashleyww93 commented on June 1, 2024

How would you see this working?

You might have more than on migration that needs to be applied.

By adding this you risk “fake applying” migrations you need.

If this is something people need, it might be better to have the CLI interactive, and provide you with a list of migrations it’s going to run, where you can mark some as “already used”.

from mikro-orm.

rubiin avatar rubiin commented on June 1, 2024

This wont introduce anything new rather builds on top of how currently migration works. It would just mark the migrations as applied without actually running anything.

from mikro-orm.

boenrobot avatar boenrobot commented on June 1, 2024

IMHO, it would be best for the ecosystem as a whole if this is implemented in Umzug instead of in MikroORM. The migrator of MikroORM is built on top of Umzug.

from mikro-orm.

rubiin avatar rubiin commented on June 1, 2024

@B4nan did you mean something like this when you said logging https://www.doctrine-project.org/projects/doctrine-migrations/en/3.5/reference/managing-migrations.html#dry-run

also i agree with this maybe it will be better to have separate log/unlog commands next to them, seems like a better approach already

from mikro-orm.

B4nan avatar B4nan commented on June 1, 2024

Though then again, being able to log/unlog multiple at once may also come in handy in more exotic setups... and in that case, I would expect all migration names to be in the sequence that they would be logged/unlogged. Combined with a "--dry-run" like option to see the migrations that are to be migrated, but not migrate them, one could implement log/unlog that behaves like up/down with a --fake flag, if they really need to.

I don't think we need that (or should I say, I am not interested in writing that myself, and I still don't like the idea of --fake flag in the first place). Let's not complicate things, OP asked for a way to add lines to the migrations table, that's what I can add easily, the rest doesn't feel justified for the added complexity.

Also for dry running, I don't see how it could work, as the migration can contain dynamic stuff, e.g. query execution, not just the addSql calls. But I surely see a value in that option, maybe we could just log the code of such migrations, as running them might already bring side effects.

from mikro-orm.

rubiin avatar rubiin commented on June 1, 2024

The scenario I am trying to cover is :
Lets say I modified some columns to a table externally
Later on I wrote a migration to cover the change. Since the change was already applied, I wanted the orm to be able to track this as well(which is why adding it to the migration table without actually running it) .

from mikro-orm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.