This commit is contained in:
seb
2026-07-31 09:00:14 +02:00
parent 4f98082061
commit 99dd76075e
24 changed files with 1477 additions and 1175 deletions

View File

@@ -34,12 +34,19 @@ export const TABLES = [
export const PROCEDURES = ['getnextnumberwithprefixandpadding'];
/** Drop before tables — breaks company ↔ customergroup cycle for purge. */
export const CONSTRAINTS = [
`IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE name = N'FK_company_poscustomergroup')
ALTER TABLE company DROP CONSTRAINT FK_company_poscustomergroup;`,
];
export function buildPurgeSql() {
const drops = [
...PROCEDURES.map(
(name) =>
`IF OBJECT_ID(N'dbo.${name}', N'P') IS NOT NULL DROP PROCEDURE dbo.[${name}];`,
),
...CONSTRAINTS,
...TABLES.map(
(name) =>
`IF OBJECT_ID(N'dbo.${name}', N'U') IS NOT NULL DROP TABLE dbo.[${name}];`,