refactor: introduce database provider abstraction, isolate MSSQL layer

- Add provider contract (src/providers/provider.js): query() -> {rows,
  rowsAffected, insertId}, callback transaction(fn), exec() for stored
  procs, initialize/purge lifecycle
- Add MssqlProvider (src/providers/mssql/index.js) wrapping an mssql
  ConnectionPool with normalized results, tx commit/rollback and
  constraint-error classifiers (unique 2627/2601, FK 547)
- LibDashStore constructor now takes a provider instead of a pool
  (breaking); adds LibDashStore.create() async factory; keeps pool as
  transitional bridge until store modules are converted (see TODO.md)
- Move MSSQL-specific code into the provider: src/sql/* ->
  src/providers/mssql/queries/*, src/schema.js ->
  src/providers/mssql/schema.js, purge SQL -> purgeSql.js
- Update scripts, generate-schema-graph.js and package.json exports
  (./providers/mssql, ./providers/provider)
- Add TODO.md with the remaining provider/SQLite migration plan

No SQL or behavioral changes.
This commit is contained in:
seb
2026-09-20 13:51:01 +02:00
parent 67b3f8b6bf
commit 53a20c4353
184 changed files with 508 additions and 192 deletions

View File

@@ -0,0 +1,34 @@
export const GET_CHILD_COUNT = `
SELECT COUNT(*) AS count
FROM article
WHERE fatherarticle_id = @articleId
`;
export const GET_LIST_IDS = `
SELECT articlelist_id AS articlelistId, optionslist_id AS optionslistId
FROM article
WHERE id = @articleId
`;
export const DELETE_PICS_BY_ARTICLE = `
DELETE p
FROM pic p
INNER JOIN articlepic ap ON ap.pic_id = p.id
WHERE ap.article_id = @articleId
`;
export const DELETE_BY_ID = `
DELETE FROM article
WHERE id = @articleId
`;
export const DELETE_ARTICLELIST = `
DELETE FROM articlelist
WHERE id = @id
`;
export const DELETE_OPTIONSLIST = `
DELETE FROM optionslist
WHERE id = @id
`;