Skip to content

All migrations run in a single transaction — migrations must not open their own connections #1211

Description

@RUKAYAT-CODER

TypeORM's default migrationsTransactionMode is all: every migration runs in one shared transaction. A migration that calls queryRunner.connection.createQueryRunner() opens a separate pooled connection that cannot see uncommitted tables created earlier in the run (this is exactly the fix-invoice-number-sequence failure fixed in #1195).

This is a footgun for future migrations: any migration that uses connection.createQueryRunner() (or does SELECT on tables created by an earlier migration in the same run) will fail from scratch.

Fix: document the constraint in the migrations README (prefer the passed queryRunner), and/or audit existing migrations for createQueryRunner() usage.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third Campaign

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions