diff --git a/backend/src/api/donations.ts b/backend/src/api/donations.ts index 7d7b81b0d..c3ab24f33 100644 --- a/backend/src/api/donations.ts +++ b/backend/src/api/donations.ts @@ -105,7 +105,7 @@ class Donations { private async $addDonationToDatabase(btcPaid: number, handle: string, orderId: string, imageUrl: string): Promise { try { const connection = await DB.pool.getConnection(); - const query = `INSERT INTO donations(added, amount, handle, order_id, imageUrl) VALUES (NOW(), ?, ?, ?, ?)`; + const query = `INSERT IGNORE INTO donations(added, amount, handle, order_id, imageUrl) VALUES (NOW(), ?, ?, ?, ?)`; const params: (string | number)[] = [ btcPaid, handle, diff --git a/mariadb-structure.sql b/mariadb-structure.sql index 770f8029a..b7eed37c4 100644 --- a/mariadb-structure.sql +++ b/mariadb-structure.sql @@ -100,3 +100,5 @@ ALTER TABLE `donations` ALTER TABLE `donations` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; + +ALTER TABLE `donations` ADD UNIQUE(`order_id`);