migration

This commit is contained in:
2026-07-10 15:11:29 +03:30
parent 7a5d2bb137
commit c41f5567c5
3 changed files with 6 additions and 0 deletions
+1
View File
@@ -13,5 +13,6 @@ export default new DataSource({
database: process.env.DB_NAME, database: process.env.DB_NAME,
entities: [join(__dirname, '../**/*.entity.{js,ts}')], entities: [join(__dirname, '../**/*.entity.{js,ts}')],
migrations: [join(__dirname, '/migrations/*.{js,ts}')], migrations: [join(__dirname, '/migrations/*.{js,ts}')],
migrationsTransactionMode: 'each',
...(isCompiled ? {} : { requireTsNode: true }), ...(isCompiled ? {} : { requireTsNode: true }),
}); });
@@ -15,9 +15,11 @@ const NEW_NOTIFICATION_KEYS = [NotificationScenarioKey.DEPOSIT_RECEIPT_SUBMITTED
* Only adds the new enum values. Postgres forbids using a newly added enum * Only adds the new enum values. Postgres forbids using a newly added enum
* value in the same transaction it was created in, so seeding the actual * value in the same transaction it was created in, so seeding the actual
* scenario rows is handled by the follow-up `SeedDepositScenarios` migration. * scenario rows is handled by the follow-up `SeedDepositScenarios` migration.
* `transaction = false` commits ADD VALUE immediately (required by Postgres).
*/ */
export class AddDepositScenarios1722000000000 implements MigrationInterface { export class AddDepositScenarios1722000000000 implements MigrationInterface {
name = 'AddDepositScenarios1722000000000'; name = 'AddDepositScenarios1722000000000';
transaction = false;
public async up(queryRunner: QueryRunner): Promise<void> { public async up(queryRunner: QueryRunner): Promise<void> {
for (const key of NEW_SMS_KEYS) { for (const key of NEW_SMS_KEYS) {
+3
View File
@@ -15,5 +15,8 @@ export function getTypeOrmOptions(): TypeOrmModuleOptions {
// by both reserves and reserve_status_history). Use migrations instead. // by both reserves and reserve_status_history). Use migrations instead.
synchronize: false, synchronize: false,
migrationsRun: true, migrationsRun: true,
// Each migration commits separately so Postgres enum ADD VALUE can be
// used by a follow-up seed migration (unsafe in the same transaction).
migrationsTransactionMode: 'each',
}; };
} }