From 374f3cd7ebcf204c34e848cda5a7957a98ebfa5f Mon Sep 17 00:00:00 2001 From: einhorn_b Date: Fri, 29 Dec 2023 14:43:35 +0100 Subject: [PATCH] make backendTransactionId unique --- .../0003-refactor_transaction_recipe/BackendTransaction.ts | 4 ++-- dlt-database/migrations/0003-refactor_transaction_recipe.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dlt-database/entity/0003-refactor_transaction_recipe/BackendTransaction.ts b/dlt-database/entity/0003-refactor_transaction_recipe/BackendTransaction.ts index 12b9c83cf..89dd3dbb0 100644 --- a/dlt-database/entity/0003-refactor_transaction_recipe/BackendTransaction.ts +++ b/dlt-database/entity/0003-refactor_transaction_recipe/BackendTransaction.ts @@ -9,8 +9,8 @@ export class BackendTransaction extends BaseEntity { @PrimaryGeneratedColumn('increment', { unsigned: true, type: 'bigint' }) id: number - @Column({ name: 'backend_transaction_id', type: 'bigint', unsigned: true, nullable: true }) - backendTransactionId?: number + @Column({ name: 'backend_transaction_id', type: 'bigint', unsigned: true, unique: true }) + backendTransactionId: number @ManyToOne(() => Transaction, (transaction) => transaction.backendTransactions) @JoinColumn({ name: 'transaction_id' }) diff --git a/dlt-database/migrations/0003-refactor_transaction_recipe.ts b/dlt-database/migrations/0003-refactor_transaction_recipe.ts index a3e8265e7..ac427cd21 100644 --- a/dlt-database/migrations/0003-refactor_transaction_recipe.ts +++ b/dlt-database/migrations/0003-refactor_transaction_recipe.ts @@ -72,6 +72,7 @@ export async function upgrade(queryFn: (query: string, values?: any[]) => Promis \`confirmed_at\` DATETIME NULL DEFAULT NULL, \`verifiedOnBackend\` TINYINT NOT NULL DEFAULT 0, PRIMARY KEY (\`id\`), + UNIQUE (\`backend_transaction_id\`), FOREIGN KEY (\`transaction_id\`) REFERENCES transactions(id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; `,