feat(schema): replace manifestarticle article_id FK with sku, rename articlesupplier sku/stock fields

This commit is contained in:
seb
2026-09-15 09:24:43 +02:00
parent e56f725bd9
commit 00bbd2e764
18 changed files with 1720 additions and 1877 deletions

View File

@@ -3,10 +3,8 @@ import {
DELETE_BY_ID,
DELETE_OPTIONSLIST,
DELETE_PICS_BY_ARTICLE,
DETACH_MANIFEST_ARTICLES,
GET_CHILD_COUNT,
GET_LIST_IDS,
GET_NAME_FOR_DELETE,
} from '../../sql/articleDelete.js';
import resolveArticleBySku from './resolveArticleBySku.js';
import request from '../request.js';
@@ -26,7 +24,7 @@ export default function del(pool) {
* await store.article.delete(42, 'SKU-1');
*/
return async (googleAuthId, sku) => {
const { articleId, languageId } = await resolve(googleAuthId, sku);
const { articleId } = await resolve(googleAuthId, sku);
const childCount = await pool
.request()
@@ -37,15 +35,6 @@ export default function del(pool) {
throw new Error('Article has children');
}
const nameResult = await pool
.request()
.input('articleId', articleId)
.input('languageId', languageId)
.query(GET_NAME_FOR_DELETE);
const name = nameResult.recordset[0]?.name ?? sku;
const suffix = `article ${name} deleted`;
const listIds = await pool
.request()
.input('articleId', articleId)
@@ -57,11 +46,6 @@ export default function del(pool) {
await tx.begin();
try {
await request(pool, tx)
.input('articleId', articleId)
.input('suffix', suffix)
.query(DETACH_MANIFEST_ARTICLES);
await request(pool, tx)
.input('articleId', articleId)
.query(DELETE_PICS_BY_ARTICLE);