Comments (10)
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.
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.
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.
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.
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.
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.
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.
@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.
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.
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)
- Automatic migration generation creates new changes even if schema is up to date HOT 1
- Entity Generator is extremely slow on large databases and has bugs HOT 13
- Maximum call stack exceed with double $none operator HOT 1
- I want to use mixin as base class but mikroorm dedup the base class by name
- Make the `getSingleResult()` add limit to the query
- Updating a Json field in postgresql does not remove properties from the json in the DB HOT 1
- Unknown behavior: SynctaxError: Unexpected number at new Function (<anonymous>)
- Order by doesn’t work with embeddable fields inside populated entity
- There is an issue when attempting to fetch an entity by referencing a field within an 'Embeddable' object that belongs to a related entity
- Inintended caching of EntityManager by EntityRepository from within a transactional context HOT 8
- Get Change Sets reports changes in embeddable entity with no changes HOT 1
- Naming errors in Entity Generator HOT 4
- DriverException when using pessimistic LockMode in combination with populate
- In-memory DB compatible with MikroORM and NestJS for integration testing (API endpoints)
- Updating JSON fields with another JSON structure, merges with existing structure instead of replacing the old one
- this.driver.getPlatform is not a function HOT 1
- Minor type issue: em.fork does not use entityManager type set by MikroORM.init HOT 1
- Issues getting populate hint typechecking to work HOT 3
- CLI with NodeNext module/moduleResolution
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mikro-orm.