This commit is contained in:
seb
2026-09-22 08:31:01 +02:00
parent cca131d83a
commit dce65db435
11 changed files with 1453 additions and 30 deletions

View File

@@ -1,5 +1,7 @@
/** Drop order = reverse of schema create dependency order. */
export const TABLES = [
'manifestattachment',
'file',
'companyuser',
'syncpos',
'companysetting',
@@ -48,10 +50,12 @@ export const PROCEDURES = [
export const VIEWS = ['v_entity_company_number'];
/** Drop before tables — breaks company ↔ customergroup cycle for purge. */
/** Drop before tables — drops all foreign keys so all tables can be purged safely. */
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;`,
`DECLARE @dropFkSql NVARCHAR(MAX) = N'';
SELECT @dropFkSql += N'ALTER TABLE ' + QUOTENAME(OBJECT_SCHEMA_NAME(parent_object_id)) + N'.' + QUOTENAME(OBJECT_NAME(parent_object_id)) + N' DROP CONSTRAINT ' + QUOTENAME(name) + N';'
FROM sys.foreign_keys;
IF @dropFkSql <> N'' EXEC sp_executesql @dropFkSql;`,
];
export function buildPurgeSql() {

View File

@@ -76,7 +76,8 @@ WHERE ean = @ean
/** Link an article to its father article and mark the father. */
export const UPDATE_FATHER_BY_SKU = `
UPDATE article
SET fatherarticle_id = @fatherArticleId
SET fatherarticle_id = @fatherArticleId,
fathersort = COALESCE(@fathersort, 0)
WHERE sku = @sku
`;

View File

@@ -53,6 +53,6 @@ WHERE id = @googleAuthId
export const SET_PROFILE = `
UPDATE google_auth
SET picture = @picture, picturebinary = @pictureBinary, sub = @sub
SET picture = @picture, picturebinary = CONVERT(VARBINARY(MAX), @pictureBinary), sub = @sub
WHERE id = @googleAuthId
`;