make backendTransactionId unique

This commit is contained in:
einhorn_b 2023-12-29 14:43:35 +01:00
parent 3b6240de1f
commit 374f3cd7eb
2 changed files with 3 additions and 2 deletions

View File

@ -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' })

View File

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