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; `,