New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration generate continuously repeats entries #3280
Comments
I saw the comment on #3277 but even if you are not naming things, every new migration file will drop and readd things that are already there. Even using @Index() the type hint shows you can provide a name, i.e. @Index("my_index_name") but it will always be dropped and readded whenever you make a new migration file. With a list of 30 tables, every time I run a new build migration, I get a huge list of changes I have to delete most of them to find my the one I want. |
Would be helpful if you put all this code into minimal possible reproduction repository and let us check it. |
I don't know if it was caused by the same issue as @ktwbc was having, but I also ran into the issue of TypeORM generating these migrations endlessly. My issue turned out to be that I named the class of the entity differently from the filename. Perhaps TypeORM could ensure that the exported class names match the filenames and throw an error otherwise? |
I seem to be having a similar issue where I have a view entity for a postgres view and whenever I try to generate a migration, the migration wants to drop the view twice, and the revert wants to put it back twice. |
I'm having this same issue, but only with mysql/mariadb, tested on a postgres db and It works. You can recreate this just by creating an entity and generating a migration, then run the migration and generate again, it gonna be the same code from the first migration. Hope this can get some attention... :( |
The same issue here, typeorm version 0.2.24, connection type MySQL, generate migration creates the same entities over and over again, it doesn't produce diff |
Same here. Connection type is postgres (pg v12), was working fine with 0.2.22, upgrading to 0.2.24 causes generate to generate migrations every time it is run, w/o any changes to the entities themselves. This is a real blocker for moving to 0.2.24 |
It seems to be fixed in 0.2.28 |
🎉 Code was merged in so I'll be closing this out. |
This is issue is still present when using mariadb with typeorm version 0.2.31. Steps to reproduce:
I don't think this is supposed to happen. |
Not sure if our case is related to this. Here's a sample repository. We could see migration files in the first two commits. Entity definition demonstrated from Typeorm doc.Define joining table with naming convention demonstrated in Typeorm doc.Self-defined joining table and specify name in JoinTable annotation. |
Please ignore my above comment since I found another issue related to it. |
Issue type:
[ ] question
[ X] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ]
cordova
[ ]
mongodb
[ ]
mssql
[X ]
mysql
/mariadb
[ ]
oracle
[ ]
postgres
[ ]
sqlite
[ ]
sqljs
[ ]
react-native
[ ]
expo
TypeORM version:
[X ]
latest
[ ]
@next
[ ]
0.x.x
(or put your version here)Steps to reproduce or a small repository showing the problem:
When building model files and relying on building and running migrations, TypeORM will constantly drop and add the same indexes over and over.
Table A:
Table B:
Steps:
a. build model files per above
b. Run migrate build:
ts-node ./node_modules/typeorm/cli.js migration:generate -f ormconfig-local -c migrate -n 'mySql'
c. view build migration:
d. Run migration:
ts-node ./node_modules/typeorm/cli.js migration:run -f ormconfig-local -c migrate
e. Run a migration:generate again
Expect:
No migration file should be generated because nothing has changed
Instead:
A new migration file is generated dropping and adding indexes. This actually happens on indexes and foreign keys. It makes no difference whether you try to name the IDX/FK yourself or let TypeOrm do it. On my 30 table database, I get a huge list of every index and foreign keys being removed and added, it never recognizes nothing has changed.
The text was updated successfully, but these errors were encountered: