We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Composite keys always re added to migration with migration:generate
Fields should not be re added in each new migrations.
Migrations like this are generated, despite the fields are already in DB and generated in the previous migration.
class MyMigration123456789 implements MigrationInterface { name = 'MyMigration123456789' public async up(queryRunner: QueryRunner): Promise<void> { await queryRunner.query(`ALTER TABLE "a_to_b" DROP CONSTRAINT "FK_a675a44c6c2ee41bcbb73024360"`); await queryRunner.query(`ALTER TABLE "a_to_b" DROP CONSTRAINT "FK_8325ba645245ab1a1b176ae1473"`); await queryRunner.query(`ALTER TABLE "a_to_b" ALTER COLUMN "a_id" int`); await queryRunner.query(`ALTER TABLE "a_to_b" ALTER COLUMN "b_id" int`); await queryRunner.query(`ALTER TABLE "a_to_b" ALTER COLUMN "a_id" int`); await queryRunner.query(`ALTER TABLE "a_to_b" ALTER COLUMN "b_id" int`); await queryRunner.query(`ALTER TABLE "a_to_b" ADD CONSTRAINT "FK_a675a44c6c2ee41bcbb73024360" FOREIGN KEY ("a_id") REFERENCES "step"("a_id") ON DELETE NO ACTION ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE "a_to_b" ADD CONSTRAINT "FK_8325ba645245ab1a1b176ae1473" FOREIGN KEY ("b_id") REFERENCES "b"("b_id") ON DELETE NO ACTION ON UPDATE NO ACTION`); } }
1 - Create entities like this:
@Entity() export default class A { @PrimaryGeneratedColumn() aId: number @Column({ length: 255 }) name: string @OneToMany(() => AToB, aToB => aToB.a) aToBs: AToB[] } @Entity() export default class B { @PrimaryGeneratedColumn() bId: number @Column({ length: 255 }) name: string @OneToMany(() => AToB, aToB => aToB.b) aToBs: AToB[] } @Entity() export default class AToB { @Column() isEnable: boolean @ApiProperty({ type: () => Step }) @ManyToOne(() => A, a=> a.aToBs, { primary: true }) @JoinColumn({ name: 'a_id' }) a: A @Column({ nullable: true, primary: true }) aId: number @ApiProperty({ type: () => ProjectType }) @ManyToOne(() => B, b=> b.aToBs, { primary: true }) @JoinColumn({ name: 'b_Id' }) b: B @Column({ nullable: true, primary: true }) bId: number }
2 - Generate new migration.
My command:
ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config src/ormconfig.ts migration:generate -n MyMigration
aurora-data-api
aurora-data-api-pg
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
sqlite
sqlite-abstract
sqljs
sqlserver
It might be related to #8157, but I'm not sure.
Thanks a lot guys for the help 🙏
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Issue Description
Composite keys always re added to migration with
migration:generate
Expected Behavior
Fields should not be re added in each new migrations.
Actual Behavior
Migrations like this are generated, despite the fields are already in DB and generated in the previous migration.
Steps to Reproduce
1 - Create entities like this:
2 - Generate new migration.
My command:
My Environment
Additional Context
Relevant Database Driver(s)
aurora-data-api
aurora-data-api-pg
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
It might be related to #8157, but I'm not sure.
Thanks a lot guys for the help 🙏
The text was updated successfully, but these errors were encountered: