rework internal order system
This commit is contained in:
@@ -134,8 +134,10 @@ class CleanupService {
|
||||
}
|
||||
const { rows } = await pool.query('SELECT COUNT(*)::int AS count FROM bestellungen');
|
||||
const count = rows[0].count;
|
||||
// Delete related linking tables first, then main table
|
||||
await pool.query('DELETE FROM ausruestung_anfrage_bestellung WHERE bestellung_id IN (SELECT id FROM bestellungen)');
|
||||
await pool.query('TRUNCATE bestellungen CASCADE');
|
||||
await pool.query('ALTER SEQUENCE bestellungen_id_seq RESTART WITH 1');
|
||||
try { await pool.query('ALTER SEQUENCE bestellungen_id_seq RESTART WITH 1'); } catch { /* sequence may not exist */ }
|
||||
logger.info(`Cleanup: truncated bestellungen (${count} rows) and reset sequence`);
|
||||
return { count, deleted: true };
|
||||
}
|
||||
@@ -147,8 +149,10 @@ class CleanupService {
|
||||
}
|
||||
const { rows } = await pool.query('SELECT COUNT(*)::int AS count FROM ausruestung_anfragen');
|
||||
const count = rows[0].count;
|
||||
// Delete linking table first
|
||||
await pool.query('DELETE FROM ausruestung_anfrage_bestellung WHERE anfrage_id IN (SELECT id FROM ausruestung_anfragen)');
|
||||
await pool.query('TRUNCATE ausruestung_anfragen CASCADE');
|
||||
await pool.query('ALTER SEQUENCE ausruestung_anfragen_id_seq RESTART WITH 1');
|
||||
try { await pool.query('ALTER SEQUENCE ausruestung_anfragen_id_seq RESTART WITH 1'); } catch { /* sequence may not exist */ }
|
||||
logger.info(`Cleanup: truncated ausruestung_anfragen (${count} rows) and reset sequence`);
|
||||
return { count, deleted: true };
|
||||
}
|
||||
@@ -161,7 +165,7 @@ class CleanupService {
|
||||
const { rows } = await pool.query('SELECT COUNT(*)::int AS count FROM issues');
|
||||
const count = rows[0].count;
|
||||
await pool.query('TRUNCATE issues CASCADE');
|
||||
await pool.query('ALTER SEQUENCE issues_id_seq RESTART WITH 1');
|
||||
try { await pool.query('ALTER SEQUENCE issues_id_seq RESTART WITH 1'); } catch { /* sequence may not exist */ }
|
||||
logger.info(`Cleanup: truncated issues (${count} rows) and reset sequence`);
|
||||
return { count, deleted: true };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user