dineway 0.2.27 → 0.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{activity-DWlF3FUa.mjs → activity-CpXJEs3L.mjs} +1 -1
- package/dist/{activity-events-BYksOnTL.mjs → activity-events-hoMsbNbY.mjs} +1 -1
- package/dist/api/route-utils.d.mts +8 -8
- package/dist/api/route-utils.mjs +7 -7
- package/dist/api/schemas/index.d.mts +1 -1
- package/dist/{api-BTrQ7bjs.mjs → api-BCNxeKT9.mjs} +13 -13
- package/dist/{apply-CS_138du.mjs → apply-BwNue-z4.mjs} +17 -17
- package/dist/astro/index.d.mts +7 -7
- package/dist/astro/index.mjs +1 -1
- package/dist/astro/middleware/auth.d.mts +7 -7
- package/dist/astro/middleware/redirect.mjs +4 -4
- package/dist/astro/middleware/seed.d.mts +1 -1
- package/dist/astro/middleware/seed.mjs +1 -1
- package/dist/astro/middleware.mjs +58 -57
- package/dist/astro/routes/api/admin/briefing.mjs +11 -11
- package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +6 -6
- package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +6 -6
- package/dist/astro/routes/api/admin/bylines/index.mjs +6 -6
- package/dist/astro/routes/api/admin/comments/_id_/status.mjs +4 -4
- package/dist/astro/routes/api/admin/comments/_id_.mjs +3 -3
- package/dist/astro/routes/api/admin/comments/bulk.mjs +3 -3
- package/dist/astro/routes/api/admin/comments/counts.mjs +3 -3
- package/dist/astro/routes/api/admin/comments/index.mjs +3 -3
- package/dist/astro/routes/api/admin/context/_id_/history.mjs +20 -20
- package/dist/astro/routes/api/admin/context/_id_/index.mjs +20 -20
- package/dist/astro/routes/api/admin/context/_id_/review.mjs +21 -21
- package/dist/astro/routes/api/admin/context/_id_/supersede.mjs +21 -21
- package/dist/astro/routes/api/admin/context/diff.mjs +20 -20
- package/dist/astro/routes/api/admin/context/index.mjs +21 -21
- package/dist/astro/routes/api/admin/context/stale.mjs +20 -20
- package/dist/astro/routes/api/admin/hitl-requests/_id_/index.mjs +21 -21
- package/dist/astro/routes/api/admin/hitl-requests/_id_/resolve.mjs +21 -21
- package/dist/astro/routes/api/admin/hitl-requests/index.mjs +21 -21
- package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +20 -20
- package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +39 -39
- package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +39 -39
- package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +33 -33
- package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +39 -39
- package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +39 -39
- package/dist/astro/routes/api/admin/plugins/index.mjs +33 -33
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +33 -33
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +39 -39
- package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +33 -33
- package/dist/astro/routes/api/admin/plugins/updates.mjs +33 -33
- package/dist/astro/routes/api/admin/review-requests/_id_/index.mjs +3 -3
- package/dist/astro/routes/api/admin/review-requests/_id_/resolve.mjs +21 -21
- package/dist/astro/routes/api/admin/review-requests/index.mjs +21 -21
- package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +33 -33
- package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +33 -33
- package/dist/astro/routes/api/auth/dev-bypass.mjs +1 -1
- package/dist/astro/routes/api/auth/me.mjs +2 -2
- package/dist/astro/routes/api/auth/setup-token/index.mjs +2 -2
- package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +4 -4
- package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +8 -8
- package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +8 -8
- package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +5 -5
- package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/_id_.mjs +4 -4
- package/dist/astro/routes/api/content/_collection_/index.mjs +4 -4
- package/dist/astro/routes/api/dashboard.mjs +6 -6
- package/dist/astro/routes/api/health.mjs +1 -1
- package/dist/astro/routes/api/import/probe.d.mts +2 -2
- package/dist/astro/routes/api/import/probe.mjs +7 -7
- package/dist/astro/routes/api/import/wordpress/analyze.mjs +4 -4
- package/dist/astro/routes/api/import/wordpress/execute.d.mts +7 -7
- package/dist/astro/routes/api/import/wordpress/execute.mjs +25 -25
- package/dist/astro/routes/api/import/wordpress/media.d.mts +7 -7
- package/dist/astro/routes/api/import/wordpress/media.mjs +2 -2
- package/dist/astro/routes/api/import/wordpress/prepare.mjs +22 -22
- package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +7 -7
- package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +21 -21
- package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +10 -10
- package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +7 -7
- package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +26 -26
- package/dist/astro/routes/api/manifest.mjs +1 -1
- package/dist/astro/routes/api/mcp.mjs +56 -60
- package/dist/astro/routes/api/media/_id_/confirm.mjs +2 -2
- package/dist/astro/routes/api/media/upload-url.mjs +2 -2
- package/dist/astro/routes/api/media.mjs +3 -3
- package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +21 -21
- package/dist/astro/routes/api/menus/_name_/items.mjs +21 -21
- package/dist/astro/routes/api/menus/_name_/reorder.mjs +21 -21
- package/dist/astro/routes/api/menus/_name_/translations.mjs +21 -21
- package/dist/astro/routes/api/menus/_name_.mjs +21 -21
- package/dist/astro/routes/api/menus/index.mjs +21 -21
- package/dist/astro/routes/api/openapi.json.mjs +1 -1
- package/dist/astro/routes/api/redirects/404s/index.mjs +3 -3
- package/dist/astro/routes/api/redirects/404s/summary.mjs +3 -3
- package/dist/astro/routes/api/redirects/_id_.mjs +22 -22
- package/dist/astro/routes/api/redirects/index.mjs +22 -22
- package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +35 -35
- package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +35 -35
- package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +35 -35
- package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +35 -35
- package/dist/astro/routes/api/schema/collections/index.mjs +35 -35
- package/dist/astro/routes/api/schema/index.mjs +5 -5
- package/dist/astro/routes/api/schema/orphans/_slug_.mjs +33 -33
- package/dist/astro/routes/api/schema/orphans/index.mjs +33 -33
- package/dist/astro/routes/api/search/enable.mjs +4 -4
- package/dist/astro/routes/api/search/index.mjs +4 -4
- package/dist/astro/routes/api/search/rebuild.mjs +4 -4
- package/dist/astro/routes/api/search/stats.mjs +4 -4
- package/dist/astro/routes/api/search/suggest.mjs +4 -4
- package/dist/astro/routes/api/sections/_slug_.mjs +21 -21
- package/dist/astro/routes/api/sections/index.mjs +21 -21
- package/dist/astro/routes/api/settings.mjs +21 -21
- package/dist/astro/routes/api/setup/dev-bypass.mjs +16 -16
- package/dist/astro/routes/api/setup/index.mjs +16 -16
- package/dist/astro/routes/api/setup/status.mjs +1 -1
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +23 -23
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +23 -23
- package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +23 -23
- package/dist/astro/routes/api/taxonomies/index.mjs +23 -23
- package/dist/astro/routes/api/typegen.mjs +3 -3
- package/dist/astro/routes/api/well-known/auth.mjs +1 -1
- package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +20 -20
- package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +21 -21
- package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +21 -21
- package/dist/astro/routes/api/widget-areas/_name_.mjs +21 -21
- package/dist/astro/routes/api/widget-areas/index.mjs +21 -21
- package/dist/astro/routes/robots.txt.mjs +4 -4
- package/dist/astro/routes/sitemap-_collection_.xml.mjs +9 -9
- package/dist/astro/routes/sitemap.xml.mjs +9 -9
- package/dist/astro/session-driver.d.mts +1 -1
- package/dist/astro/session-driver.mjs +2 -2
- package/dist/astro/types.d.mts +8 -8
- package/dist/{audit-CmiNnrbj.mjs → audit-B7yDEQYd.mjs} +1 -1
- package/dist/{briefing-Cd2HhhHi.mjs → briefing-Bw06giSR.mjs} +5 -5
- package/dist/{briefing-BoIXsh3Y.mjs → briefing-DXk509e9.mjs} +1 -1
- package/dist/{bundle-DicQY2p2.mjs → bundle-BElk5hXQ.mjs} +1 -1
- package/dist/{byline-MGIfM2Is.mjs → byline-Dvn80pJf.mjs} +4 -4
- package/dist/{byline-fields-BJ5_tYj8.d.mts → byline-fields-Cvl12BTB.d.mts} +60 -60
- package/dist/{bylines-CL8Z6AxI.mjs → bylines-CB_5AVLg.mjs} +4 -4
- package/dist/{bylines-t_uHsP44.mjs → bylines-TcwJ0D4l.mjs} +3 -3
- package/dist/{cache-DrNKKDn0.mjs → cache-BFya-uMt.mjs} +1 -1
- package/dist/{chunks-Bw3_BuVW.mjs → chunks--xBaAjew.mjs} +1 -1
- package/dist/cli/index.mjs +20 -20
- package/dist/cli/plugin-kit.d.mts +7 -7
- package/dist/cli/plugin-kit.mjs +1 -1
- package/dist/client/index.d.mts +7 -7
- package/dist/{client-factory-DXfeovxp.mjs → client-factory-DlGsDQ0a.mjs} +1 -1
- package/dist/{comment-DuDtCn-f.mjs → comment-C4foIr7l.mjs} +1 -1
- package/dist/{comment-reaction-NZjadbiB.mjs → comment-reaction-CqMFa-tO.mjs} +1 -1
- package/dist/{comments-Csi3B9JI.mjs → comments-BvQiuHgk.mjs} +1 -1
- package/dist/{content-CzUrmMC3.mjs → content-GsliU3xN.mjs} +2 -2
- package/dist/{content-refresh-C_jcjzOr.mjs → content-refresh-Q60Srx4f.mjs} +2 -2
- package/dist/{context-D1WiuHGe.mjs → context-BxRv0tDb.mjs} +2 -2
- package/dist/{context-BET1jeas.mjs → context-or1S7D_Z.mjs} +6 -6
- package/dist/{context-route-helpers-CgVXswZ_.mjs → context-route-helpers-DtRDW7-Y.mjs} +1 -1
- package/dist/{dashboard-CKAH1KwM.mjs → dashboard-DP_aGVlw.mjs} +4 -4
- package/dist/db/index.d.mts +2 -2
- package/dist/db/index.mjs +1 -1
- package/dist/{discovery-SVnRaAxj.mjs → discovery-BgLQroSv.mjs} +2 -2
- package/dist/{field-defs-cache-BIHTU5Yj.mjs → field-defs-cache-BJL-9Sbz.mjs} +1 -1
- package/dist/{fts-manager-BB44uXMm.mjs → fts-manager-DYyjVJRg.mjs} +1 -1
- package/dist/{hitl-requests-D117gyhv.mjs → hitl-requests-LFIR0lUw.mjs} +1 -1
- package/dist/{hitl-route-helpers-BasbaWwG.mjs → hitl-route-helpers-Ct3-l199.mjs} +2 -2
- package/dist/{import-BCY1k1zB.mjs → import-CAJjk6sz.mjs} +3 -3
- package/dist/{index-DNNw5fp0.d.mts → index-QJMl0Apm.d.mts} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +52 -52
- package/dist/{jsonld-CxMRDv02.d.mts → jsonld-TNycwGyO.d.mts} +2 -2
- package/dist/{load-C-cMlsPv.mjs → load-BU9-SNEM.mjs} +1 -1
- package/dist/{loader-CsX5pTud.mjs → loader-08U88vtS.mjs} +2 -2
- package/dist/{mcp-reviewed-executor-BwI0ylf3.mjs → mcp-reviewed-executor-BIV-Nt4z.mjs} +3 -3
- package/dist/media/local-runtime.d.mts +7 -7
- package/dist/media/local-runtime.mjs +2 -2
- package/dist/{media-4xtXwq7L.mjs → media-fMI0fkpM.mjs} +1 -1
- package/dist/{menus-CRmcWAM5.mjs → menus-BCaZ124X.mjs} +1 -1
- package/dist/{menus-Cu3TUXyl.mjs → menus-BN5-WSeA.mjs} +3 -3
- package/dist/page/index.d.mts +8 -8
- package/dist/plugin-utils.d.mts +7 -7
- package/dist/plugins/adapt-sandbox-entry.d.mts +7 -7
- package/dist/{plugins-BC9Rb6PJ.mjs → plugins-BZAfdnht.mjs} +2 -2
- package/dist/{public-url-UpDevWVD.d.mts → public-url-Bn-FXyxd.d.mts} +1 -1
- package/dist/{public-url-BPnL5sTj.d.mts → public-url-K_8Mlvos.d.mts} +1 -1
- package/dist/{publication-authorization-Bq4B0KIL.mjs → publication-authorization-BvguiESO.mjs} +22 -6
- package/dist/{query-MvFwA1uK.mjs → query-D-HFo-qW.mjs} +2 -2
- package/dist/{query-BAfn0Uxp.mjs → query-yPx_JZSl.mjs} +13 -12
- package/dist/{redirect-CnG6nJ4H.mjs → redirect-CI5NFP2I.mjs} +1 -1
- package/dist/{redirects-lCwNKPUn.mjs → redirects-B8UMik8v.mjs} +2 -2
- package/dist/{registry-QxrUJAWY.mjs → registry-CtSVFnzD.mjs} +4 -4
- package/dist/{review-requests-uI-yUXcr.mjs → review-requests-BrEd3zb5.mjs} +1 -1
- package/dist/{review-requests-DaYnr3XR.mjs → review-requests-DwV5pW9w.mjs} +1 -1
- package/dist/{review-route-helpers-BvX04ahf.mjs → review-route-helpers-BjTgKhRr.mjs} +1 -1
- package/dist/{runner-CQnzfBpD.mjs → runner-CGD7YoW6.mjs} +504 -463
- package/dist/{runner-o39FihbH.d.mts → runner-Dp8Tt7SJ.d.mts} +1 -1
- package/dist/runtime.d.mts +7 -7
- package/dist/runtime.mjs +2 -2
- package/dist/schema-CrYkp-Bo.mjs +8 -0
- package/dist/{search-BtCHwx_Z.mjs → search-xzdgq7jq.mjs} +3 -3
- package/dist/{sections-BM88PvRO.mjs → sections-CIXoe8VF.mjs} +2 -2
- package/dist/seed/index.d.mts +2 -2
- package/dist/seed/index.mjs +15 -15
- package/dist/seo/index.d.mts +2 -2
- package/dist/seo/index.mjs +5 -5
- package/dist/{seo-CTXMR4YD.mjs → seo-2qDQ_eM-.mjs} +1 -1
- package/dist/{seo-BhMH6i2e.mjs → seo-DON7g2EC.mjs} +1 -1
- package/dist/{service-evnf21UO.mjs → service-BdiBOmpe.mjs} +1 -1
- package/dist/{settings-COtVNdOx.mjs → settings-CmmYM8ML.mjs} +2 -2
- package/dist/{settings-CCqefqC9.mjs → settings-k3HDxkYk.mjs} +2 -2
- package/dist/{site-activity-kfZ9X0no.mjs → site-activity-DNFEWOyU.mjs} +1 -1
- package/dist/{site-context-D2DmqFnD.mjs → site-context-Rh2NpVP6.mjs} +10 -10
- package/dist/{taxonomies-DxtqEjcj.mjs → taxonomies-C5Dc57XI.mjs} +3 -3
- package/dist/{taxonomies-xvaQ7gVM.mjs → taxonomies-ZUyCmHr5.mjs} +4 -4
- package/dist/{taxonomy--vcXXfwc.mjs → taxonomy-Q0dtGa3h.mjs} +2 -2
- package/dist/{types-B2W3CeZN.d.mts → types-B3jx4k7V.d.mts} +69 -1
- package/dist/{types-BcpWwh4c.d.mts → types-BquoJbUs.d.mts} +14 -7
- package/dist/{types-CFvpEEOl.mjs → types-CpJhSIti.mjs} +1 -1
- package/dist/ui/server-runtime.d.mts +9 -9
- package/dist/ui/server-runtime.mjs +14 -14
- package/dist/{user-Dn3wV227.mjs → user-CQ_ujaUi.mjs} +2 -2
- package/dist/{validate-BiPYhXNZ.d.mts → validate-B244Ky-3.d.mts} +1 -1
- package/dist/{validate-BHVQSpUy.mjs → validate-DvgVQCey.mjs} +1 -1
- package/dist/version-BebwPm_l.mjs +6 -0
- package/dist/{widgets-CBCHUg_u.mjs → widgets-FttKnkpm.mjs} +1 -1
- package/dist/{zod-generator-DMlY4cI3.mjs → zod-generator-OstCAALT.mjs} +1 -1
- package/package.json +3 -3
- package/dist/schema-CD3EA3nN.mjs +0 -8
- package/dist/version-BbuynKOY.mjs +0 -6
|
@@ -25,8 +25,8 @@ var __exportAll = (all, no_symbols) => {
|
|
|
25
25
|
//#endregion
|
|
26
26
|
//#region src/database/migrations/001_initial.ts
|
|
27
27
|
var _001_initial_exports = /* @__PURE__ */ __exportAll({
|
|
28
|
-
down: () => down$
|
|
29
|
-
up: () => up$
|
|
28
|
+
down: () => down$116,
|
|
29
|
+
up: () => up$116
|
|
30
30
|
});
|
|
31
31
|
/**
|
|
32
32
|
* Initial schema migration
|
|
@@ -35,7 +35,7 @@ var _001_initial_exports = /* @__PURE__ */ __exportAll({
|
|
|
35
35
|
* by the SchemaRegistry when collections are added via the admin UI.
|
|
36
36
|
* This migration only creates system tables.
|
|
37
37
|
*/
|
|
38
|
-
async function up$
|
|
38
|
+
async function up$116(db) {
|
|
39
39
|
await db.schema.createTable("revisions").ifNotExists().addColumn("id", "text", (col) => col.primaryKey()).addColumn("collection", "text", (col) => col.notNull()).addColumn("entry_id", "text", (col) => col.notNull()).addColumn("data", "text", (col) => col.notNull()).addColumn("author_id", "text").addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).execute();
|
|
40
40
|
await db.schema.createIndex("idx_revisions_entry").ifNotExists().on("revisions").columns(["collection", "entry_id"]).execute();
|
|
41
41
|
await db.schema.createTable("taxonomies").ifNotExists().addColumn("id", "text", (col) => col.primaryKey()).addColumn("name", "text", (col) => col.notNull()).addColumn("slug", "text", (col) => col.notNull()).addColumn("label", "text", (col) => col.notNull()).addColumn("parent_id", "text").addColumn("data", "text").addUniqueConstraint("taxonomies_name_slug_unique", ["name", "slug"]).addForeignKeyConstraint("taxonomies_parent_fk", ["parent_id"], "taxonomies", ["id"], (cb) => cb.onDelete("set null")).execute();
|
|
@@ -55,7 +55,7 @@ async function up$115(db) {
|
|
|
55
55
|
await db.schema.createIndex("idx_audit_action").ifNotExists().on("audit_logs").column("action").execute();
|
|
56
56
|
await db.schema.createIndex("idx_audit_timestamp").ifNotExists().on("audit_logs").column("timestamp").execute();
|
|
57
57
|
}
|
|
58
|
-
async function down$
|
|
58
|
+
async function down$116(db) {
|
|
59
59
|
await db.schema.dropTable("audit_logs").execute();
|
|
60
60
|
await db.schema.dropTable("options").execute();
|
|
61
61
|
await db.schema.dropTable("users").execute();
|
|
@@ -68,26 +68,26 @@ async function down$115(db) {
|
|
|
68
68
|
//#endregion
|
|
69
69
|
//#region src/database/migrations/002_media_status.ts
|
|
70
70
|
var _002_media_status_exports = /* @__PURE__ */ __exportAll({
|
|
71
|
-
down: () => down$
|
|
72
|
-
up: () => up$
|
|
71
|
+
down: () => down$115,
|
|
72
|
+
up: () => up$115
|
|
73
73
|
});
|
|
74
74
|
/**
|
|
75
75
|
* Add status column to media table for tracking upload state.
|
|
76
76
|
* Status values: 'pending' | 'ready' | 'failed'
|
|
77
77
|
*/
|
|
78
|
-
async function up$
|
|
78
|
+
async function up$115(db) {
|
|
79
79
|
await db.schema.alterTable("media").addColumn("status", "text", (col) => col.notNull().defaultTo("ready")).execute();
|
|
80
80
|
await db.schema.createIndex("idx_media_status").on("media").column("status").execute();
|
|
81
81
|
}
|
|
82
|
-
async function down$
|
|
82
|
+
async function down$115(db) {
|
|
83
83
|
await db.schema.dropIndex("idx_media_status").execute();
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
//#endregion
|
|
87
87
|
//#region src/database/migrations/003_schema_registry.ts
|
|
88
88
|
var _003_schema_registry_exports = /* @__PURE__ */ __exportAll({
|
|
89
|
-
down: () => down$
|
|
90
|
-
up: () => up$
|
|
89
|
+
down: () => down$114,
|
|
90
|
+
up: () => up$114
|
|
91
91
|
});
|
|
92
92
|
/**
|
|
93
93
|
* Migration: Schema Registry Tables
|
|
@@ -95,14 +95,14 @@ var _003_schema_registry_exports = /* @__PURE__ */ __exportAll({
|
|
|
95
95
|
* Creates the schema registry tables that store collection and field definitions.
|
|
96
96
|
* This enables dynamic schema management where the database is the source of truth.
|
|
97
97
|
*/
|
|
98
|
-
async function up$
|
|
98
|
+
async function up$114(db) {
|
|
99
99
|
await db.schema.createTable("_dineway_collections").addColumn("id", "text", (col) => col.primaryKey()).addColumn("slug", "text", (col) => col.notNull().unique()).addColumn("label", "text", (col) => col.notNull()).addColumn("label_singular", "text").addColumn("description", "text").addColumn("icon", "text").addColumn("supports", "text").addColumn("source", "text").addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).execute();
|
|
100
100
|
await db.schema.createTable("_dineway_fields").addColumn("id", "text", (col) => col.primaryKey()).addColumn("collection_id", "text", (col) => col.notNull()).addColumn("slug", "text", (col) => col.notNull()).addColumn("label", "text", (col) => col.notNull()).addColumn("type", "text", (col) => col.notNull()).addColumn("column_type", "text", (col) => col.notNull()).addColumn("required", "integer", (col) => col.defaultTo(0)).addColumn("unique", "integer", (col) => col.defaultTo(0)).addColumn("default_value", "text").addColumn("validation", "text").addColumn("widget", "text").addColumn("options", "text").addColumn("sort_order", "integer", (col) => col.defaultTo(0)).addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addForeignKeyConstraint("fields_collection_fk", ["collection_id"], "_dineway_collections", ["id"], (cb) => cb.onDelete("cascade")).execute();
|
|
101
101
|
await db.schema.createIndex("idx_fields_collection_slug").on("_dineway_fields").columns(["collection_id", "slug"]).unique().execute();
|
|
102
102
|
await db.schema.createIndex("idx_fields_collection").on("_dineway_fields").column("collection_id").execute();
|
|
103
103
|
await db.schema.createIndex("idx_fields_sort").on("_dineway_fields").columns(["collection_id", "sort_order"]).execute();
|
|
104
104
|
}
|
|
105
|
-
async function down$
|
|
105
|
+
async function down$114(db) {
|
|
106
106
|
await db.schema.dropTable("_dineway_fields").execute();
|
|
107
107
|
await db.schema.dropTable("_dineway_collections").execute();
|
|
108
108
|
}
|
|
@@ -110,8 +110,8 @@ async function down$113(db) {
|
|
|
110
110
|
//#endregion
|
|
111
111
|
//#region src/database/migrations/004_plugins.ts
|
|
112
112
|
var _004_plugins_exports = /* @__PURE__ */ __exportAll({
|
|
113
|
-
down: () => down$
|
|
114
|
-
up: () => up$
|
|
113
|
+
down: () => down$113,
|
|
114
|
+
up: () => up$113
|
|
115
115
|
});
|
|
116
116
|
/**
|
|
117
117
|
* Migration: Plugin System Tables
|
|
@@ -121,7 +121,7 @@ var _004_plugins_exports = /* @__PURE__ */ __exportAll({
|
|
|
121
121
|
*
|
|
122
122
|
* @see PLUGIN-SYSTEM.md § Plugin Storage
|
|
123
123
|
*/
|
|
124
|
-
async function up$
|
|
124
|
+
async function up$113(db) {
|
|
125
125
|
await db.schema.createTable("_plugin_storage").addColumn("plugin_id", "text", (col) => col.notNull()).addColumn("collection", "text", (col) => col.notNull()).addColumn("id", "text", (col) => col.notNull()).addColumn("data", "text", (col) => col.notNull()).addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addPrimaryKeyConstraint("pk_plugin_storage", [
|
|
126
126
|
"plugin_id",
|
|
127
127
|
"collection",
|
|
@@ -139,7 +139,7 @@ async function up$112(db) {
|
|
|
139
139
|
"index_name"
|
|
140
140
|
]).execute();
|
|
141
141
|
}
|
|
142
|
-
async function down$
|
|
142
|
+
async function down$113(db) {
|
|
143
143
|
await db.schema.dropTable("_plugin_indexes").execute();
|
|
144
144
|
await db.schema.dropTable("_plugin_state").execute();
|
|
145
145
|
await db.schema.dropTable("_plugin_storage").execute();
|
|
@@ -148,8 +148,8 @@ async function down$112(db) {
|
|
|
148
148
|
//#endregion
|
|
149
149
|
//#region src/database/migrations/005_menus.ts
|
|
150
150
|
var _005_menus_exports = /* @__PURE__ */ __exportAll({
|
|
151
|
-
down: () => down$
|
|
152
|
-
up: () => up$
|
|
151
|
+
down: () => down$112,
|
|
152
|
+
up: () => up$112
|
|
153
153
|
});
|
|
154
154
|
/**
|
|
155
155
|
* Navigation Menus migration
|
|
@@ -157,13 +157,13 @@ var _005_menus_exports = /* @__PURE__ */ __exportAll({
|
|
|
157
157
|
* Creates tables for admin-editable navigation menus.
|
|
158
158
|
* Menu items can reference content entries, taxonomy terms, or custom URLs.
|
|
159
159
|
*/
|
|
160
|
-
async function up$
|
|
160
|
+
async function up$112(db) {
|
|
161
161
|
await db.schema.createTable("_dineway_menus").addColumn("id", "text", (col) => col.primaryKey()).addColumn("name", "text", (col) => col.notNull().unique()).addColumn("label", "text", (col) => col.notNull()).addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).execute();
|
|
162
162
|
await db.schema.createTable("_dineway_menu_items").addColumn("id", "text", (col) => col.primaryKey()).addColumn("menu_id", "text", (col) => col.notNull()).addColumn("parent_id", "text").addColumn("sort_order", "integer", (col) => col.notNull().defaultTo(0)).addColumn("type", "text", (col) => col.notNull()).addColumn("reference_collection", "text").addColumn("reference_id", "text").addColumn("custom_url", "text").addColumn("label", "text", (col) => col.notNull()).addColumn("title_attr", "text").addColumn("target", "text").addColumn("css_classes", "text").addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addForeignKeyConstraint("menu_items_menu_fk", ["menu_id"], "_dineway_menus", ["id"], (cb) => cb.onDelete("cascade")).addForeignKeyConstraint("menu_items_parent_fk", ["parent_id"], "_dineway_menu_items", ["id"], (cb) => cb.onDelete("cascade")).execute();
|
|
163
163
|
await db.schema.createIndex("idx_menu_items_menu").on("_dineway_menu_items").columns(["menu_id", "sort_order"]).execute();
|
|
164
164
|
await db.schema.createIndex("idx_menu_items_parent").on("_dineway_menu_items").column("parent_id").execute();
|
|
165
165
|
}
|
|
166
|
-
async function down$
|
|
166
|
+
async function down$112(db) {
|
|
167
167
|
await db.schema.dropTable("_dineway_menu_items").execute();
|
|
168
168
|
await db.schema.dropTable("_dineway_menus").execute();
|
|
169
169
|
}
|
|
@@ -171,8 +171,8 @@ async function down$111(db) {
|
|
|
171
171
|
//#endregion
|
|
172
172
|
//#region src/database/migrations/006_taxonomy_defs.ts
|
|
173
173
|
var _006_taxonomy_defs_exports = /* @__PURE__ */ __exportAll({
|
|
174
|
-
down: () => down$
|
|
175
|
-
up: () => up$
|
|
174
|
+
down: () => down$111,
|
|
175
|
+
up: () => up$111
|
|
176
176
|
});
|
|
177
177
|
/**
|
|
178
178
|
* Taxonomy definitions migration
|
|
@@ -180,7 +180,7 @@ var _006_taxonomy_defs_exports = /* @__PURE__ */ __exportAll({
|
|
|
180
180
|
* Adds _dineway_taxonomy_defs table to store taxonomy definitions (category, tag, custom)
|
|
181
181
|
* and seeds default category and tag taxonomies.
|
|
182
182
|
*/
|
|
183
|
-
async function up$
|
|
183
|
+
async function up$111(db) {
|
|
184
184
|
await db.schema.createTable("_dineway_taxonomy_defs").addColumn("id", "text", (col) => col.primaryKey()).addColumn("name", "text", (col) => col.notNull().unique()).addColumn("label", "text", (col) => col.notNull()).addColumn("label_singular", "text").addColumn("hierarchical", "integer", (col) => col.defaultTo(0)).addColumn("collections", "text").addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).execute();
|
|
185
185
|
await db.insertInto("_dineway_taxonomy_defs").values([{
|
|
186
186
|
id: "taxdef_category",
|
|
@@ -198,22 +198,22 @@ async function up$110(db) {
|
|
|
198
198
|
collections: JSON.stringify(["posts"])
|
|
199
199
|
}]).execute();
|
|
200
200
|
}
|
|
201
|
-
async function down$
|
|
201
|
+
async function down$111(db) {
|
|
202
202
|
await db.schema.dropTable("_dineway_taxonomy_defs").execute();
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
//#endregion
|
|
206
206
|
//#region src/database/migrations/007_widgets.ts
|
|
207
207
|
var _007_widgets_exports = /* @__PURE__ */ __exportAll({
|
|
208
|
-
down: () => down$
|
|
209
|
-
up: () => up$
|
|
208
|
+
down: () => down$110,
|
|
209
|
+
up: () => up$110
|
|
210
210
|
});
|
|
211
|
-
async function up$
|
|
211
|
+
async function up$110(db) {
|
|
212
212
|
await db.schema.createTable("_dineway_widget_areas").addColumn("id", "text", (col) => col.primaryKey()).addColumn("name", "text", (col) => col.notNull().unique()).addColumn("label", "text", (col) => col.notNull()).addColumn("description", "text").addColumn("created_at", "text", (col) => col.defaultTo(sql`CURRENT_TIMESTAMP`)).execute();
|
|
213
213
|
await db.schema.createTable("_dineway_widgets").addColumn("id", "text", (col) => col.primaryKey()).addColumn("area_id", "text", (col) => col.notNull().references("_dineway_widget_areas.id").onDelete("cascade")).addColumn("sort_order", "integer", (col) => col.notNull().defaultTo(0)).addColumn("type", "text", (col) => col.notNull()).addColumn("title", "text").addColumn("content", "text").addColumn("menu_name", "text").addColumn("component_id", "text").addColumn("component_props", "text").addColumn("created_at", "text", (col) => col.defaultTo(sql`CURRENT_TIMESTAMP`)).execute();
|
|
214
214
|
await db.schema.createIndex("idx_widgets_area").on("_dineway_widgets").columns(["area_id", "sort_order"]).execute();
|
|
215
215
|
}
|
|
216
|
-
async function down$
|
|
216
|
+
async function down$110(db) {
|
|
217
217
|
await db.schema.dropTable("_dineway_widgets").execute();
|
|
218
218
|
await db.schema.dropTable("_dineway_widget_areas").execute();
|
|
219
219
|
}
|
|
@@ -221,8 +221,8 @@ async function down$109(db) {
|
|
|
221
221
|
//#endregion
|
|
222
222
|
//#region src/database/migrations/008_auth.ts
|
|
223
223
|
var _008_auth_exports = /* @__PURE__ */ __exportAll({
|
|
224
|
-
down: () => down$
|
|
225
|
-
up: () => up$
|
|
224
|
+
down: () => down$109,
|
|
225
|
+
up: () => up$109
|
|
226
226
|
});
|
|
227
227
|
/**
|
|
228
228
|
* Auth migration - passkey-first authentication
|
|
@@ -236,7 +236,7 @@ var _008_auth_exports = /* @__PURE__ */ __exportAll({
|
|
|
236
236
|
* - Creates oauth_accounts table (external provider links)
|
|
237
237
|
* - Creates allowed_domains table (self-signup)
|
|
238
238
|
*/
|
|
239
|
-
async function up$
|
|
239
|
+
async function up$109(db) {
|
|
240
240
|
await db.schema.createTable("users_new").addColumn("id", "text", (col) => col.primaryKey()).addColumn("email", "text", (col) => col.notNull().unique()).addColumn("name", "text").addColumn("avatar_url", "text").addColumn("role", "integer", (col) => col.notNull().defaultTo(10)).addColumn("email_verified", "integer", (col) => col.notNull().defaultTo(0)).addColumn("data", "text").addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).execute();
|
|
241
241
|
await sql`
|
|
242
242
|
INSERT INTO users_new (id, email, name, role, data, created_at, updated_at)
|
|
@@ -269,7 +269,7 @@ async function up$108(db) {
|
|
|
269
269
|
await db.schema.createTable("auth_challenges").addColumn("challenge", "text", (col) => col.primaryKey()).addColumn("type", "text", (col) => col.notNull()).addColumn("user_id", "text").addColumn("data", "text").addColumn("expires_at", "text", (col) => col.notNull()).addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).execute();
|
|
270
270
|
await db.schema.createIndex("idx_auth_challenges_expires").on("auth_challenges").column("expires_at").execute();
|
|
271
271
|
}
|
|
272
|
-
async function down$
|
|
272
|
+
async function down$109(db) {
|
|
273
273
|
await db.schema.dropTable("auth_challenges").execute();
|
|
274
274
|
await db.schema.dropTable("allowed_domains").execute();
|
|
275
275
|
await db.schema.dropTable("oauth_accounts").execute();
|
|
@@ -302,8 +302,8 @@ async function down$108(db) {
|
|
|
302
302
|
//#endregion
|
|
303
303
|
//#region src/database/migrations/009_user_disabled.ts
|
|
304
304
|
var _009_user_disabled_exports = /* @__PURE__ */ __exportAll({
|
|
305
|
-
down: () => down$
|
|
306
|
-
up: () => up$
|
|
305
|
+
down: () => down$108,
|
|
306
|
+
up: () => up$108
|
|
307
307
|
});
|
|
308
308
|
/**
|
|
309
309
|
* User disabled column - for soft-disabling users
|
|
@@ -312,19 +312,19 @@ var _009_user_disabled_exports = /* @__PURE__ */ __exportAll({
|
|
|
312
312
|
* - Adds disabled column to users table (INTEGER, default 0)
|
|
313
313
|
* - Disabled users cannot log in
|
|
314
314
|
*/
|
|
315
|
-
async function up$
|
|
315
|
+
async function up$108(db) {
|
|
316
316
|
await sql`ALTER TABLE users ADD COLUMN disabled INTEGER NOT NULL DEFAULT 0`.execute(db);
|
|
317
317
|
await db.schema.createIndex("idx_users_disabled").on("users").column("disabled").execute();
|
|
318
318
|
}
|
|
319
|
-
async function down$
|
|
319
|
+
async function down$108(db) {
|
|
320
320
|
await db.schema.dropIndex("idx_users_disabled").execute();
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
//#endregion
|
|
324
324
|
//#region src/database/migrations/011_sections.ts
|
|
325
325
|
var _011_sections_exports = /* @__PURE__ */ __exportAll({
|
|
326
|
-
down: () => down$
|
|
327
|
-
up: () => up$
|
|
326
|
+
down: () => down$107,
|
|
327
|
+
up: () => up$107
|
|
328
328
|
});
|
|
329
329
|
/**
|
|
330
330
|
* Migration: Add sections tables and performance indexes
|
|
@@ -333,13 +333,13 @@ var _011_sections_exports = /* @__PURE__ */ __exportAll({
|
|
|
333
333
|
* They provide a library of pre-built page sections (heroes, CTAs, testimonials, etc.)
|
|
334
334
|
* that content authors can browse and insert with a single click.
|
|
335
335
|
*/
|
|
336
|
-
async function up$
|
|
336
|
+
async function up$107(db) {
|
|
337
337
|
await db.schema.createTable("_dineway_section_categories").addColumn("id", "text", (col) => col.primaryKey()).addColumn("slug", "text", (col) => col.notNull().unique()).addColumn("label", "text", (col) => col.notNull()).addColumn("sort_order", "integer", (col) => col.defaultTo(0)).addColumn("created_at", "text", (col) => col.defaultTo(sql`CURRENT_TIMESTAMP`)).execute();
|
|
338
338
|
await db.schema.createTable("_dineway_sections").addColumn("id", "text", (col) => col.primaryKey()).addColumn("slug", "text", (col) => col.notNull().unique()).addColumn("title", "text", (col) => col.notNull()).addColumn("description", "text").addColumn("category_id", "text", (col) => col.references("_dineway_section_categories.id").onDelete("set null")).addColumn("keywords", "text").addColumn("content", "text", (col) => col.notNull()).addColumn("preview_media_id", "text").addColumn("source", "text", (col) => col.notNull().defaultTo("user")).addColumn("theme_id", "text").addColumn("created_at", "text", (col) => col.defaultTo(sql`CURRENT_TIMESTAMP`)).addColumn("updated_at", "text", (col) => col.defaultTo(sql`CURRENT_TIMESTAMP`)).execute();
|
|
339
339
|
await db.schema.createIndex("idx_sections_category").on("_dineway_sections").columns(["category_id"]).execute();
|
|
340
340
|
await db.schema.createIndex("idx_sections_source").on("_dineway_sections").columns(["source"]).execute();
|
|
341
341
|
}
|
|
342
|
-
async function down$
|
|
342
|
+
async function down$107(db) {
|
|
343
343
|
await db.schema.dropIndex("idx_sections_source").execute();
|
|
344
344
|
await db.schema.dropIndex("idx_sections_category").execute();
|
|
345
345
|
await db.schema.dropTable("_dineway_sections").execute();
|
|
@@ -349,8 +349,8 @@ async function down$106(db) {
|
|
|
349
349
|
//#endregion
|
|
350
350
|
//#region src/database/migrations/012_search.ts
|
|
351
351
|
var _012_search_exports = /* @__PURE__ */ __exportAll({
|
|
352
|
-
down: () => down$
|
|
353
|
-
up: () => up$
|
|
352
|
+
down: () => down$106,
|
|
353
|
+
up: () => up$106
|
|
354
354
|
});
|
|
355
355
|
/**
|
|
356
356
|
* Migration: Search Support
|
|
@@ -358,11 +358,11 @@ var _012_search_exports = /* @__PURE__ */ __exportAll({
|
|
|
358
358
|
* Adds search configuration to collections and searchable flag to fields.
|
|
359
359
|
* FTS5 tables are created dynamically when search is enabled for a collection.
|
|
360
360
|
*/
|
|
361
|
-
async function up$
|
|
361
|
+
async function up$106(db) {
|
|
362
362
|
await db.schema.alterTable("_dineway_collections").addColumn("search_config", "text").execute();
|
|
363
363
|
await db.schema.alterTable("_dineway_fields").addColumn("searchable", "integer", (col) => col.defaultTo(0)).execute();
|
|
364
364
|
}
|
|
365
|
-
async function down$
|
|
365
|
+
async function down$106(db) {
|
|
366
366
|
await db.schema.alterTable("_dineway_fields").dropColumn("searchable").execute();
|
|
367
367
|
await db.schema.alterTable("_dineway_collections").dropColumn("search_config").execute();
|
|
368
368
|
}
|
|
@@ -370,8 +370,8 @@ async function down$105(db) {
|
|
|
370
370
|
//#endregion
|
|
371
371
|
//#region src/database/migrations/013_scheduled_publishing.ts
|
|
372
372
|
var _013_scheduled_publishing_exports = /* @__PURE__ */ __exportAll({
|
|
373
|
-
down: () => down$
|
|
374
|
-
up: () => up$
|
|
373
|
+
down: () => down$105,
|
|
374
|
+
up: () => up$105
|
|
375
375
|
});
|
|
376
376
|
/**
|
|
377
377
|
* Migration: Add scheduled publishing support
|
|
@@ -380,7 +380,7 @@ var _013_scheduled_publishing_exports = /* @__PURE__ */ __exportAll({
|
|
|
380
380
|
* When scheduled_at is set and status is 'scheduled', the content
|
|
381
381
|
* will be auto-published when the scheduled time is reached.
|
|
382
382
|
*/
|
|
383
|
-
async function up$
|
|
383
|
+
async function up$105(db) {
|
|
384
384
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
385
385
|
for (const tableName of tableNames) {
|
|
386
386
|
const table = { name: tableName };
|
|
@@ -395,7 +395,7 @@ async function up$104(db) {
|
|
|
395
395
|
`.execute(db);
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
|
-
async function down$
|
|
398
|
+
async function down$105(db) {
|
|
399
399
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
400
400
|
for (const tableName of tableNames) {
|
|
401
401
|
const table = { name: tableName };
|
|
@@ -412,10 +412,10 @@ async function down$104(db) {
|
|
|
412
412
|
//#endregion
|
|
413
413
|
//#region src/database/migrations/014_draft_revisions.ts
|
|
414
414
|
var _014_draft_revisions_exports = /* @__PURE__ */ __exportAll({
|
|
415
|
-
down: () => down$
|
|
416
|
-
up: () => up$
|
|
415
|
+
down: () => down$104,
|
|
416
|
+
up: () => up$104
|
|
417
417
|
});
|
|
418
|
-
async function up$
|
|
418
|
+
async function up$104(db) {
|
|
419
419
|
const tables = await db.selectFrom("_dineway_collections").select("slug").execute();
|
|
420
420
|
for (const row of tables) {
|
|
421
421
|
const tableName = `ec_${row.slug}`;
|
|
@@ -437,7 +437,7 @@ async function up$103(db) {
|
|
|
437
437
|
`.execute(db);
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
|
-
async function down$
|
|
440
|
+
async function down$104(db) {
|
|
441
441
|
const tables = await db.selectFrom("_dineway_collections").select("slug").execute();
|
|
442
442
|
for (const row of tables) {
|
|
443
443
|
const tableName = `ec_${row.slug}`;
|
|
@@ -461,8 +461,8 @@ async function down$103(db) {
|
|
|
461
461
|
//#endregion
|
|
462
462
|
//#region src/database/migrations/015_indexes.ts
|
|
463
463
|
var _015_indexes_exports = /* @__PURE__ */ __exportAll({
|
|
464
|
-
down: () => down$
|
|
465
|
-
up: () => up$
|
|
464
|
+
down: () => down$103,
|
|
465
|
+
up: () => up$103
|
|
466
466
|
});
|
|
467
467
|
/**
|
|
468
468
|
* Add performance indexes for common query patterns.
|
|
@@ -475,7 +475,7 @@ var _015_indexes_exports = /* @__PURE__ */ __exportAll({
|
|
|
475
475
|
* 5. Retroactive author_id + updated_at on existing ec_* content tables
|
|
476
476
|
* (new tables get these from createContentTable() in registry.ts)
|
|
477
477
|
*/
|
|
478
|
-
async function up$
|
|
478
|
+
async function up$103(db) {
|
|
479
479
|
await db.schema.createIndex("idx_media_mime_type").on("media").column("mime_type").execute();
|
|
480
480
|
await db.schema.createIndex("idx_media_filename").on("media").column("filename").execute();
|
|
481
481
|
await db.schema.createIndex("idx_media_created_at").on("media").column("created_at").execute();
|
|
@@ -495,7 +495,7 @@ async function up$102(db) {
|
|
|
495
495
|
`.execute(db);
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
|
-
async function down$
|
|
498
|
+
async function down$103(db) {
|
|
499
499
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
500
500
|
for (const tableName of tableNames) {
|
|
501
501
|
const table = { name: tableName };
|
|
@@ -513,8 +513,8 @@ async function down$102(db) {
|
|
|
513
513
|
//#endregion
|
|
514
514
|
//#region src/database/migrations/016_api_tokens.ts
|
|
515
515
|
var _016_api_tokens_exports = /* @__PURE__ */ __exportAll({
|
|
516
|
-
down: () => down$
|
|
517
|
-
up: () => up$
|
|
516
|
+
down: () => down$102,
|
|
517
|
+
up: () => up$102
|
|
518
518
|
});
|
|
519
519
|
/**
|
|
520
520
|
* API token tables for programmatic access.
|
|
@@ -528,7 +528,7 @@ var _016_api_tokens_exports = /* @__PURE__ */ __exportAll({
|
|
|
528
528
|
* created only part of the schema before failing and never recorded the
|
|
529
529
|
* migration as applied.
|
|
530
530
|
*/
|
|
531
|
-
async function up$
|
|
531
|
+
async function up$102(db) {
|
|
532
532
|
await db.schema.createTable("_dineway_api_tokens").ifNotExists().addColumn("id", "text", (col) => col.primaryKey()).addColumn("name", "text", (col) => col.notNull()).addColumn("token_hash", "text", (col) => col.notNull().unique()).addColumn("prefix", "text", (col) => col.notNull()).addColumn("user_id", "text", (col) => col.notNull()).addColumn("scopes", "text", (col) => col.notNull()).addColumn("expires_at", "text").addColumn("last_used_at", "text").addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addForeignKeyConstraint("api_tokens_user_fk", ["user_id"], "users", ["id"], (cb) => cb.onDelete("cascade")).execute();
|
|
533
533
|
await db.schema.createIndex("idx_api_tokens_token_hash").ifNotExists().on("_dineway_api_tokens").column("token_hash").execute();
|
|
534
534
|
await db.schema.createIndex("idx_api_tokens_user_id").ifNotExists().on("_dineway_api_tokens").column("user_id").execute();
|
|
@@ -537,7 +537,7 @@ async function up$101(db) {
|
|
|
537
537
|
await db.schema.createIndex("idx_oauth_tokens_expires").ifNotExists().on("_dineway_oauth_tokens").column("expires_at").execute();
|
|
538
538
|
await db.schema.createTable("_dineway_device_codes").ifNotExists().addColumn("device_code", "text", (col) => col.primaryKey()).addColumn("user_code", "text", (col) => col.notNull().unique()).addColumn("scopes", "text", (col) => col.notNull()).addColumn("user_id", "text").addColumn("status", "text", (col) => col.notNull().defaultTo("pending")).addColumn("expires_at", "text", (col) => col.notNull()).addColumn("interval", "integer", (col) => col.notNull().defaultTo(5)).addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).execute();
|
|
539
539
|
}
|
|
540
|
-
async function down$
|
|
540
|
+
async function down$102(db) {
|
|
541
541
|
await db.schema.dropTable("_dineway_device_codes").ifExists().execute();
|
|
542
542
|
await db.schema.dropTable("_dineway_oauth_tokens").ifExists().execute();
|
|
543
543
|
await db.schema.dropTable("_dineway_api_tokens").ifExists().execute();
|
|
@@ -546,8 +546,8 @@ async function down$101(db) {
|
|
|
546
546
|
//#endregion
|
|
547
547
|
//#region src/database/migrations/017_authorization_codes.ts
|
|
548
548
|
var _017_authorization_codes_exports = /* @__PURE__ */ __exportAll({
|
|
549
|
-
down: () => down$
|
|
550
|
-
up: () => up$
|
|
549
|
+
down: () => down$101,
|
|
550
|
+
up: () => up$101
|
|
551
551
|
});
|
|
552
552
|
/**
|
|
553
553
|
* Authorization codes for OAuth 2.1 Authorization Code + PKCE flow.
|
|
@@ -557,20 +557,20 @@ var _017_authorization_codes_exports = /* @__PURE__ */ __exportAll({
|
|
|
557
557
|
*
|
|
558
558
|
* Also adds client_id tracking to oauth_tokens for per-client revocation.
|
|
559
559
|
*/
|
|
560
|
-
async function up$
|
|
560
|
+
async function up$101(db) {
|
|
561
561
|
await db.schema.createTable("_dineway_authorization_codes").addColumn("code_hash", "text", (col) => col.primaryKey()).addColumn("client_id", "text", (col) => col.notNull()).addColumn("redirect_uri", "text", (col) => col.notNull()).addColumn("user_id", "text", (col) => col.notNull()).addColumn("scopes", "text", (col) => col.notNull()).addColumn("code_challenge", "text", (col) => col.notNull()).addColumn("code_challenge_method", "text", (col) => col.notNull().defaultTo("S256")).addColumn("resource", "text").addColumn("expires_at", "text", (col) => col.notNull()).addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addForeignKeyConstraint("auth_codes_user_fk", ["user_id"], "users", ["id"], (cb) => cb.onDelete("cascade")).execute();
|
|
562
562
|
await db.schema.createIndex("idx_auth_codes_expires").on("_dineway_authorization_codes").column("expires_at").execute();
|
|
563
563
|
await sql`ALTER TABLE _dineway_oauth_tokens ADD COLUMN client_id TEXT`.execute(db);
|
|
564
564
|
}
|
|
565
|
-
async function down$
|
|
565
|
+
async function down$101(db) {
|
|
566
566
|
await db.schema.dropTable("_dineway_authorization_codes").execute();
|
|
567
567
|
}
|
|
568
568
|
|
|
569
569
|
//#endregion
|
|
570
570
|
//#region src/database/migrations/018_seo.ts
|
|
571
571
|
var _018_seo_exports = /* @__PURE__ */ __exportAll({
|
|
572
|
-
down: () => down$
|
|
573
|
-
up: () => up$
|
|
572
|
+
down: () => down$100,
|
|
573
|
+
up: () => up$100
|
|
574
574
|
});
|
|
575
575
|
/**
|
|
576
576
|
* Migration: SEO support
|
|
@@ -583,7 +583,7 @@ var _018_seo_exports = /* @__PURE__ */ __exportAll({
|
|
|
583
583
|
* need it. The `has_seo` flag controls whether the admin shows SEO fields
|
|
584
584
|
* and whether the collection's content appears in sitemaps.
|
|
585
585
|
*/
|
|
586
|
-
async function up$
|
|
586
|
+
async function up$100(db) {
|
|
587
587
|
await db.schema.createTable("_dineway_seo").addColumn("collection", "text", (col) => col.notNull()).addColumn("content_id", "text", (col) => col.notNull()).addColumn("seo_title", "text").addColumn("seo_description", "text").addColumn("seo_image", "text").addColumn("seo_canonical", "text").addColumn("seo_no_index", "integer", (col) => col.notNull().defaultTo(0)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addPrimaryKeyConstraint("_dineway_seo_pk", ["collection", "content_id"]).execute();
|
|
588
588
|
await sql`
|
|
589
589
|
CREATE INDEX idx_dineway_seo_collection
|
|
@@ -594,7 +594,7 @@ async function up$99(db) {
|
|
|
594
594
|
ADD COLUMN has_seo INTEGER NOT NULL DEFAULT 0
|
|
595
595
|
`.execute(db);
|
|
596
596
|
}
|
|
597
|
-
async function down$
|
|
597
|
+
async function down$100(db) {
|
|
598
598
|
await sql`DROP TABLE IF EXISTS _dineway_seo`.execute(db);
|
|
599
599
|
await sql`
|
|
600
600
|
ALTER TABLE _dineway_collections
|
|
@@ -605,8 +605,8 @@ async function down$99(db) {
|
|
|
605
605
|
//#endregion
|
|
606
606
|
//#region src/database/migrations/019_i18n.ts
|
|
607
607
|
var _019_i18n_exports = /* @__PURE__ */ __exportAll({
|
|
608
|
-
down: () => down$
|
|
609
|
-
up: () => up$
|
|
608
|
+
down: () => down$99,
|
|
609
|
+
up: () => up$99
|
|
610
610
|
});
|
|
611
611
|
/**
|
|
612
612
|
* Quote an identifier for use in raw SQL. Escapes embedded double-quotes
|
|
@@ -719,7 +719,7 @@ async function upPostgres(db) {
|
|
|
719
719
|
ADD COLUMN translatable INTEGER NOT NULL DEFAULT 1
|
|
720
720
|
`.execute(db);
|
|
721
721
|
}
|
|
722
|
-
async function up$
|
|
722
|
+
async function up$99(db) {
|
|
723
723
|
if (!isSqlite(db)) return upPostgres(db);
|
|
724
724
|
const orphanedTmps = await listTablesLike(db, "ec_%_i18n_tmp");
|
|
725
725
|
for (const tmpName of orphanedTmps) {
|
|
@@ -836,7 +836,7 @@ async function downPostgres(db) {
|
|
|
836
836
|
await sql`ALTER TABLE ${sql.ref(t)} DROP COLUMN translation_group`.execute(db);
|
|
837
837
|
}
|
|
838
838
|
}
|
|
839
|
-
async function down$
|
|
839
|
+
async function down$99(db) {
|
|
840
840
|
if (!isSqlite(db)) return downPostgres(db);
|
|
841
841
|
await sql`
|
|
842
842
|
ALTER TABLE _dineway_fields
|
|
@@ -943,8 +943,8 @@ async function down$98(db) {
|
|
|
943
943
|
//#endregion
|
|
944
944
|
//#region src/database/migrations/020_collection_url_pattern.ts
|
|
945
945
|
var _020_collection_url_pattern_exports = /* @__PURE__ */ __exportAll({
|
|
946
|
-
down: () => down$
|
|
947
|
-
up: () => up$
|
|
946
|
+
down: () => down$98,
|
|
947
|
+
up: () => up$98
|
|
948
948
|
});
|
|
949
949
|
/**
|
|
950
950
|
* Migration: URL pattern for collections
|
|
@@ -953,13 +953,13 @@ var _020_collection_url_pattern_exports = /* @__PURE__ */ __exportAll({
|
|
|
953
953
|
* can declare its own URL structure (e.g. "/{slug}" for pages, "/blog/{slug}"
|
|
954
954
|
* for posts). Used for menu URL resolution, sitemaps, and path-based lookups.
|
|
955
955
|
*/
|
|
956
|
-
async function up$
|
|
956
|
+
async function up$98(db) {
|
|
957
957
|
await sql`
|
|
958
958
|
ALTER TABLE _dineway_collections
|
|
959
959
|
ADD COLUMN url_pattern TEXT
|
|
960
960
|
`.execute(db);
|
|
961
961
|
}
|
|
962
|
-
async function down$
|
|
962
|
+
async function down$98(db) {
|
|
963
963
|
await sql`
|
|
964
964
|
ALTER TABLE _dineway_collections
|
|
965
965
|
DROP COLUMN url_pattern
|
|
@@ -969,8 +969,8 @@ async function down$97(db) {
|
|
|
969
969
|
//#endregion
|
|
970
970
|
//#region src/database/migrations/021_remove_section_categories.ts
|
|
971
971
|
var _021_remove_section_categories_exports = /* @__PURE__ */ __exportAll({
|
|
972
|
-
down: () => down$
|
|
973
|
-
up: () => up$
|
|
972
|
+
down: () => down$97,
|
|
973
|
+
up: () => up$97
|
|
974
974
|
});
|
|
975
975
|
/**
|
|
976
976
|
* Migration: Remove section categories
|
|
@@ -979,12 +979,12 @@ var _021_remove_section_categories_exports = /* @__PURE__ */ __exportAll({
|
|
|
979
979
|
* Rather than building the missing UI for a feature with very little need at this stage,
|
|
980
980
|
* we're removing the feature entirely.
|
|
981
981
|
*/
|
|
982
|
-
async function up$
|
|
982
|
+
async function up$97(db) {
|
|
983
983
|
await db.schema.dropIndex("idx_sections_category").ifExists().execute();
|
|
984
984
|
await db.schema.alterTable("_dineway_sections").dropColumn("category_id").execute();
|
|
985
985
|
await db.schema.dropTable("_dineway_section_categories").execute();
|
|
986
986
|
}
|
|
987
|
-
async function down$
|
|
987
|
+
async function down$97(db) {
|
|
988
988
|
await db.schema.createTable("_dineway_section_categories").addColumn("id", "text", (col) => col.primaryKey()).addColumn("slug", "text", (col) => col.notNull().unique()).addColumn("label", "text", (col) => col.notNull()).addColumn("sort_order", "integer", (col) => col.defaultTo(0)).addColumn("created_at", "text", (col) => col.defaultTo(sql`CURRENT_TIMESTAMP`)).execute();
|
|
989
989
|
await db.schema.alterTable("_dineway_sections").addColumn("category_id", "text", (col) => col.references("_dineway_section_categories.id").onDelete("set null")).execute();
|
|
990
990
|
await db.schema.createIndex("idx_sections_category").on("_dineway_sections").columns(["category_id"]).execute();
|
|
@@ -993,8 +993,8 @@ async function down$96(db) {
|
|
|
993
993
|
//#endregion
|
|
994
994
|
//#region src/database/migrations/022_marketplace_plugin_state.ts
|
|
995
995
|
var _022_marketplace_plugin_state_exports = /* @__PURE__ */ __exportAll({
|
|
996
|
-
down: () => down$
|
|
997
|
-
up: () => up$
|
|
996
|
+
down: () => down$96,
|
|
997
|
+
up: () => up$96
|
|
998
998
|
});
|
|
999
999
|
/**
|
|
1000
1000
|
* Migration: Add marketplace fields to _plugin_state
|
|
@@ -1003,7 +1003,7 @@ var _022_marketplace_plugin_state_exports = /* @__PURE__ */ __exportAll({
|
|
|
1003
1003
|
* whether a plugin was installed from config or marketplace,
|
|
1004
1004
|
* and which marketplace version is installed.
|
|
1005
1005
|
*/
|
|
1006
|
-
async function up$
|
|
1006
|
+
async function up$96(db) {
|
|
1007
1007
|
await sql`
|
|
1008
1008
|
ALTER TABLE _plugin_state
|
|
1009
1009
|
ADD COLUMN source TEXT NOT NULL DEFAULT 'config'
|
|
@@ -1018,7 +1018,7 @@ async function up$95(db) {
|
|
|
1018
1018
|
WHERE source = 'marketplace'
|
|
1019
1019
|
`.execute(db);
|
|
1020
1020
|
}
|
|
1021
|
-
async function down$
|
|
1021
|
+
async function down$96(db) {
|
|
1022
1022
|
await sql`
|
|
1023
1023
|
DROP INDEX IF EXISTS idx_plugin_state_source
|
|
1024
1024
|
`.execute(db);
|
|
@@ -1035,8 +1035,8 @@ async function down$95(db) {
|
|
|
1035
1035
|
//#endregion
|
|
1036
1036
|
//#region src/database/migrations/023_plugin_metadata.ts
|
|
1037
1037
|
var _023_plugin_metadata_exports = /* @__PURE__ */ __exportAll({
|
|
1038
|
-
down: () => down$
|
|
1039
|
-
up: () => up$
|
|
1038
|
+
down: () => down$95,
|
|
1039
|
+
up: () => up$95
|
|
1040
1040
|
});
|
|
1041
1041
|
/**
|
|
1042
1042
|
* Migration: Add display metadata to _plugin_state
|
|
@@ -1045,7 +1045,7 @@ var _023_plugin_metadata_exports = /* @__PURE__ */ __exportAll({
|
|
|
1045
1045
|
* so the admin UI can show meaningful info without re-fetching
|
|
1046
1046
|
* from the marketplace on every page load.
|
|
1047
1047
|
*/
|
|
1048
|
-
async function up$
|
|
1048
|
+
async function up$95(db) {
|
|
1049
1049
|
await sql`
|
|
1050
1050
|
ALTER TABLE _plugin_state
|
|
1051
1051
|
ADD COLUMN display_name TEXT
|
|
@@ -1055,7 +1055,7 @@ async function up$94(db) {
|
|
|
1055
1055
|
ADD COLUMN description TEXT
|
|
1056
1056
|
`.execute(db);
|
|
1057
1057
|
}
|
|
1058
|
-
async function down$
|
|
1058
|
+
async function down$95(db) {
|
|
1059
1059
|
await sql`
|
|
1060
1060
|
ALTER TABLE _plugin_state
|
|
1061
1061
|
DROP COLUMN description
|
|
@@ -1069,8 +1069,8 @@ async function down$94(db) {
|
|
|
1069
1069
|
//#endregion
|
|
1070
1070
|
//#region src/database/migrations/024_media_placeholders.ts
|
|
1071
1071
|
var _024_media_placeholders_exports = /* @__PURE__ */ __exportAll({
|
|
1072
|
-
down: () => down$
|
|
1073
|
-
up: () => up$
|
|
1072
|
+
down: () => down$94,
|
|
1073
|
+
up: () => up$94
|
|
1074
1074
|
});
|
|
1075
1075
|
/**
|
|
1076
1076
|
* Migration: Add placeholder columns to media table
|
|
@@ -1078,7 +1078,7 @@ var _024_media_placeholders_exports = /* @__PURE__ */ __exportAll({
|
|
|
1078
1078
|
* Stores blurhash and dominant_color for LQIP (Low Quality Image Placeholder)
|
|
1079
1079
|
* support. Generated at upload time from image pixel data.
|
|
1080
1080
|
*/
|
|
1081
|
-
async function up$
|
|
1081
|
+
async function up$94(db) {
|
|
1082
1082
|
await sql`
|
|
1083
1083
|
ALTER TABLE media
|
|
1084
1084
|
ADD COLUMN blurhash TEXT
|
|
@@ -1088,7 +1088,7 @@ async function up$93(db) {
|
|
|
1088
1088
|
ADD COLUMN dominant_color TEXT
|
|
1089
1089
|
`.execute(db);
|
|
1090
1090
|
}
|
|
1091
|
-
async function down$
|
|
1091
|
+
async function down$94(db) {
|
|
1092
1092
|
await sql`
|
|
1093
1093
|
ALTER TABLE media
|
|
1094
1094
|
DROP COLUMN dominant_color
|
|
@@ -1102,8 +1102,8 @@ async function down$93(db) {
|
|
|
1102
1102
|
//#endregion
|
|
1103
1103
|
//#region src/database/migrations/025_oauth_clients.ts
|
|
1104
1104
|
var _025_oauth_clients_exports = /* @__PURE__ */ __exportAll({
|
|
1105
|
-
down: () => down$
|
|
1106
|
-
up: () => up$
|
|
1105
|
+
down: () => down$93,
|
|
1106
|
+
up: () => up$93
|
|
1107
1107
|
});
|
|
1108
1108
|
/**
|
|
1109
1109
|
* Migration: Create OAuth clients table
|
|
@@ -1114,18 +1114,18 @@ var _025_oauth_clients_exports = /* @__PURE__ */ __exportAll({
|
|
|
1114
1114
|
* Each client has a set of pre-registered redirect URIs (JSON array).
|
|
1115
1115
|
* The authorize endpoint rejects any redirect_uri not in the client's list.
|
|
1116
1116
|
*/
|
|
1117
|
-
async function up$
|
|
1117
|
+
async function up$93(db) {
|
|
1118
1118
|
await db.schema.createTable("_dineway_oauth_clients").addColumn("id", "text", (col) => col.primaryKey()).addColumn("name", "text", (col) => col.notNull()).addColumn("redirect_uris", "text", (col) => col.notNull()).addColumn("scopes", "text").addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).execute();
|
|
1119
1119
|
}
|
|
1120
|
-
async function down$
|
|
1120
|
+
async function down$93(db) {
|
|
1121
1121
|
await db.schema.dropTable("_dineway_oauth_clients").execute();
|
|
1122
1122
|
}
|
|
1123
1123
|
|
|
1124
1124
|
//#endregion
|
|
1125
1125
|
//#region src/database/migrations/026_cron_tasks.ts
|
|
1126
1126
|
var _026_cron_tasks_exports = /* @__PURE__ */ __exportAll({
|
|
1127
|
-
down: () => down$
|
|
1128
|
-
up: () => up$
|
|
1127
|
+
down: () => down$92,
|
|
1128
|
+
up: () => up$92
|
|
1129
1129
|
});
|
|
1130
1130
|
/**
|
|
1131
1131
|
* Migration: Create cron tasks table for plugin scheduled tasks.
|
|
@@ -1136,7 +1136,7 @@ var _026_cron_tasks_exports = /* @__PURE__ */ __exportAll({
|
|
|
1136
1136
|
* The `next_run_at` + `status` + `enabled` index drives the "find overdue
|
|
1137
1137
|
* tasks" query used by CronExecutor.tick().
|
|
1138
1138
|
*/
|
|
1139
|
-
async function up$
|
|
1139
|
+
async function up$92(db) {
|
|
1140
1140
|
await db.schema.createTable("_dineway_cron_tasks").addColumn("id", "text", (col) => col.primaryKey()).addColumn("plugin_id", "text", (col) => col.notNull()).addColumn("task_name", "text", (col) => col.notNull()).addColumn("schedule", "text", (col) => col.notNull()).addColumn("is_oneshot", "integer", (col) => col.notNull().defaultTo(0)).addColumn("data", "text").addColumn("next_run_at", "text", (col) => col.notNull()).addColumn("last_run_at", "text").addColumn("status", "text", (col) => col.notNull().defaultTo("idle")).addColumn("locked_at", "text").addColumn("enabled", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_cron_tasks_plugin_task", ["plugin_id", "task_name"]).execute();
|
|
1141
1141
|
await db.schema.createIndex("idx_cron_tasks_due").on("_dineway_cron_tasks").columns([
|
|
1142
1142
|
"enabled",
|
|
@@ -1145,17 +1145,17 @@ async function up$91(db) {
|
|
|
1145
1145
|
]).execute();
|
|
1146
1146
|
await db.schema.createIndex("idx_cron_tasks_plugin").on("_dineway_cron_tasks").column("plugin_id").execute();
|
|
1147
1147
|
}
|
|
1148
|
-
async function down$
|
|
1148
|
+
async function down$92(db) {
|
|
1149
1149
|
await db.schema.dropTable("_dineway_cron_tasks").execute();
|
|
1150
1150
|
}
|
|
1151
1151
|
|
|
1152
1152
|
//#endregion
|
|
1153
1153
|
//#region src/database/migrations/027_comments.ts
|
|
1154
1154
|
var _027_comments_exports = /* @__PURE__ */ __exportAll({
|
|
1155
|
-
down: () => down$
|
|
1156
|
-
up: () => up$
|
|
1155
|
+
down: () => down$91,
|
|
1156
|
+
up: () => up$91
|
|
1157
1157
|
});
|
|
1158
|
-
async function up$
|
|
1158
|
+
async function up$91(db) {
|
|
1159
1159
|
await db.schema.createTable("_dineway_comments").addColumn("id", "text", (col) => col.primaryKey()).addColumn("collection", "text", (col) => col.notNull()).addColumn("content_id", "text", (col) => col.notNull()).addColumn("parent_id", "text", (col) => col.references("_dineway_comments.id").onDelete("cascade")).addColumn("author_name", "text", (col) => col.notNull()).addColumn("author_email", "text", (col) => col.notNull()).addColumn("author_url", "text").addColumn("author_user_id", "text", (col) => col.references("users.id").onDelete("set null")).addColumn("body", "text", (col) => col.notNull()).addColumn("status", "text", (col) => col.notNull().defaultTo("pending")).addColumn("ip_hash", "text").addColumn("user_agent", "text").addColumn("moderation_metadata", "text").addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).execute();
|
|
1160
1160
|
await db.schema.createIndex("idx_comments_content").on("_dineway_comments").columns([
|
|
1161
1161
|
"collection",
|
|
@@ -1171,30 +1171,30 @@ async function up$90(db) {
|
|
|
1171
1171
|
await db.schema.alterTable("_dineway_collections").addColumn("comments_closed_after_days", "integer", (col) => col.defaultTo(90)).execute();
|
|
1172
1172
|
await db.schema.alterTable("_dineway_collections").addColumn("comments_auto_approve_users", "integer", (col) => col.defaultTo(1)).execute();
|
|
1173
1173
|
}
|
|
1174
|
-
async function down$
|
|
1174
|
+
async function down$91(db) {
|
|
1175
1175
|
await db.schema.dropTable("_dineway_comments").execute();
|
|
1176
1176
|
}
|
|
1177
1177
|
|
|
1178
1178
|
//#endregion
|
|
1179
1179
|
//#region src/database/migrations/028_drop_author_url.ts
|
|
1180
1180
|
var _028_drop_author_url_exports = /* @__PURE__ */ __exportAll({
|
|
1181
|
-
down: () => down$
|
|
1182
|
-
up: () => up$
|
|
1181
|
+
down: () => down$90,
|
|
1182
|
+
up: () => up$90
|
|
1183
1183
|
});
|
|
1184
|
-
async function up$
|
|
1184
|
+
async function up$90(db) {
|
|
1185
1185
|
await sql`ALTER TABLE _dineway_comments DROP COLUMN author_url`.execute(db);
|
|
1186
1186
|
}
|
|
1187
|
-
async function down$
|
|
1187
|
+
async function down$90(db) {
|
|
1188
1188
|
await db.schema.alterTable("_dineway_comments").addColumn("author_url", "text").execute();
|
|
1189
1189
|
}
|
|
1190
1190
|
|
|
1191
1191
|
//#endregion
|
|
1192
1192
|
//#region src/database/migrations/029_redirects.ts
|
|
1193
1193
|
var _029_redirects_exports = /* @__PURE__ */ __exportAll({
|
|
1194
|
-
down: () => down$
|
|
1195
|
-
up: () => up$
|
|
1194
|
+
down: () => down$89,
|
|
1195
|
+
up: () => up$89
|
|
1196
1196
|
});
|
|
1197
|
-
async function up$
|
|
1197
|
+
async function up$89(db) {
|
|
1198
1198
|
await db.schema.createTable("_dineway_redirects").addColumn("id", "text", (col) => col.primaryKey()).addColumn("source", "text", (col) => col.notNull()).addColumn("destination", "text", (col) => col.notNull()).addColumn("type", "integer", (col) => col.notNull().defaultTo(301)).addColumn("is_pattern", "integer", (col) => col.notNull().defaultTo(0)).addColumn("enabled", "integer", (col) => col.notNull().defaultTo(1)).addColumn("hits", "integer", (col) => col.notNull().defaultTo(0)).addColumn("last_hit_at", "text").addColumn("group_name", "text").addColumn("auto", "integer", (col) => col.notNull().defaultTo(0)).addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).execute();
|
|
1199
1199
|
await db.schema.createIndex("idx_redirects_source").on("_dineway_redirects").column("source").execute();
|
|
1200
1200
|
await db.schema.createIndex("idx_redirects_enabled").on("_dineway_redirects").column("enabled").execute();
|
|
@@ -1203,7 +1203,7 @@ async function up$88(db) {
|
|
|
1203
1203
|
await db.schema.createIndex("idx_404_log_path").on("_dineway_404_log").column("path").execute();
|
|
1204
1204
|
await db.schema.createIndex("idx_404_log_created").on("_dineway_404_log").column("created_at").execute();
|
|
1205
1205
|
}
|
|
1206
|
-
async function down$
|
|
1206
|
+
async function down$89(db) {
|
|
1207
1207
|
await db.schema.dropTable("_dineway_404_log").execute();
|
|
1208
1208
|
await db.schema.dropTable("_dineway_redirects").execute();
|
|
1209
1209
|
}
|
|
@@ -1211,8 +1211,8 @@ async function down$88(db) {
|
|
|
1211
1211
|
//#endregion
|
|
1212
1212
|
//#region src/database/migrations/030_widen_scheduled_index.ts
|
|
1213
1213
|
var _030_widen_scheduled_index_exports = /* @__PURE__ */ __exportAll({
|
|
1214
|
-
down: () => down$
|
|
1215
|
-
up: () => up$
|
|
1214
|
+
down: () => down$88,
|
|
1215
|
+
up: () => up$88
|
|
1216
1216
|
});
|
|
1217
1217
|
/**
|
|
1218
1218
|
* Migration: Widen scheduled publishing index
|
|
@@ -1221,7 +1221,7 @@ var _030_widen_scheduled_index_exports = /* @__PURE__ */ __exportAll({
|
|
|
1221
1221
|
* Published posts can now have scheduled draft changes, so widen the
|
|
1222
1222
|
* index to cover all rows where scheduled_at IS NOT NULL.
|
|
1223
1223
|
*/
|
|
1224
|
-
async function up$
|
|
1224
|
+
async function up$88(db) {
|
|
1225
1225
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1226
1226
|
for (const tableName of tableNames) {
|
|
1227
1227
|
const table = { name: tableName };
|
|
@@ -1235,7 +1235,7 @@ async function up$87(db) {
|
|
|
1235
1235
|
`.execute(db);
|
|
1236
1236
|
}
|
|
1237
1237
|
}
|
|
1238
|
-
async function down$
|
|
1238
|
+
async function down$88(db) {
|
|
1239
1239
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1240
1240
|
for (const tableName of tableNames) {
|
|
1241
1241
|
const table = { name: tableName };
|
|
@@ -1253,10 +1253,10 @@ async function down$87(db) {
|
|
|
1253
1253
|
//#endregion
|
|
1254
1254
|
//#region src/database/migrations/031_bylines.ts
|
|
1255
1255
|
var _031_bylines_exports = /* @__PURE__ */ __exportAll({
|
|
1256
|
-
down: () => down$
|
|
1257
|
-
up: () => up$
|
|
1256
|
+
down: () => down$87,
|
|
1257
|
+
up: () => up$87
|
|
1258
1258
|
});
|
|
1259
|
-
async function up$
|
|
1259
|
+
async function up$87(db) {
|
|
1260
1260
|
await db.schema.createTable("_dineway_bylines").addColumn("id", "text", (col) => col.primaryKey()).addColumn("slug", "text", (col) => col.notNull().unique()).addColumn("display_name", "text", (col) => col.notNull()).addColumn("bio", "text").addColumn("avatar_media_id", "text", (col) => col.references("media.id").onDelete("set null")).addColumn("website_url", "text").addColumn("user_id", "text", (col) => col.references("users.id").onDelete("set null")).addColumn("is_guest", "integer", (col) => col.notNull().defaultTo(0)).addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).execute();
|
|
1261
1261
|
await sql`
|
|
1262
1262
|
CREATE UNIQUE INDEX ${sql.ref("idx_bylines_user_id_unique")}
|
|
@@ -1288,7 +1288,7 @@ async function up$86(db) {
|
|
|
1288
1288
|
`.execute(db);
|
|
1289
1289
|
}
|
|
1290
1290
|
}
|
|
1291
|
-
async function down$
|
|
1291
|
+
async function down$87(db) {
|
|
1292
1292
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1293
1293
|
for (const tableName of tableNames) {
|
|
1294
1294
|
await sql`
|
|
@@ -1306,8 +1306,8 @@ async function down$86(db) {
|
|
|
1306
1306
|
//#endregion
|
|
1307
1307
|
//#region src/database/migrations/032_rate_limits.ts
|
|
1308
1308
|
var _032_rate_limits_exports = /* @__PURE__ */ __exportAll({
|
|
1309
|
-
down: () => down$
|
|
1310
|
-
up: () => up$
|
|
1309
|
+
down: () => down$86,
|
|
1310
|
+
up: () => up$86
|
|
1311
1311
|
});
|
|
1312
1312
|
/**
|
|
1313
1313
|
* Migration: Rate limits table + device code polling tracking.
|
|
@@ -1318,12 +1318,12 @@ var _032_rate_limits_exports = /* @__PURE__ */ __exportAll({
|
|
|
1318
1318
|
* 2. Add last_polled_at column to _dineway_device_codes for
|
|
1319
1319
|
* RFC 8628 slow_down enforcement.
|
|
1320
1320
|
*/
|
|
1321
|
-
async function up$
|
|
1321
|
+
async function up$86(db) {
|
|
1322
1322
|
await db.schema.createTable("_dineway_rate_limits").addColumn("key", "text", (col) => col.notNull()).addColumn("window", "text", (col) => col.notNull()).addColumn("count", "integer", (col) => col.notNull().defaultTo(1)).addPrimaryKeyConstraint("pk_rate_limits", ["key", "window"]).execute();
|
|
1323
1323
|
await db.schema.createIndex("idx_rate_limits_window").on("_dineway_rate_limits").column("window").execute();
|
|
1324
1324
|
await db.schema.alterTable("_dineway_device_codes").addColumn("last_polled_at", "text").execute();
|
|
1325
1325
|
}
|
|
1326
|
-
async function down$
|
|
1326
|
+
async function down$86(db) {
|
|
1327
1327
|
await db.schema.dropTable("_dineway_rate_limits").execute();
|
|
1328
1328
|
await db.schema.alterTable("_dineway_device_codes").dropColumn("last_polled_at").execute();
|
|
1329
1329
|
}
|
|
@@ -1331,8 +1331,8 @@ async function down$85(db) {
|
|
|
1331
1331
|
//#endregion
|
|
1332
1332
|
//#region src/database/migrations/033_optimize_content_indexes.ts
|
|
1333
1333
|
var _033_optimize_content_indexes_exports = /* @__PURE__ */ __exportAll({
|
|
1334
|
-
down: () => down$
|
|
1335
|
-
up: () => up$
|
|
1334
|
+
down: () => down$85,
|
|
1335
|
+
up: () => up$85
|
|
1336
1336
|
});
|
|
1337
1337
|
/**
|
|
1338
1338
|
* Migration: Optimize content table indexes for SQLite-compatible performance
|
|
@@ -1345,7 +1345,7 @@ var _033_optimize_content_indexes_exports = /* @__PURE__ */ __exportAll({
|
|
|
1345
1345
|
*
|
|
1346
1346
|
* Impact: Reduces row reads by 90%+ for admin panel operations on SQLite-compatible adapters.
|
|
1347
1347
|
*/
|
|
1348
|
-
async function up$
|
|
1348
|
+
async function up$85(db) {
|
|
1349
1349
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1350
1350
|
for (const tableName of tableNames) {
|
|
1351
1351
|
const table = { name: tableName };
|
|
@@ -1387,7 +1387,7 @@ async function up$84(db) {
|
|
|
1387
1387
|
WHERE status = 'trash'
|
|
1388
1388
|
`.execute(db);
|
|
1389
1389
|
}
|
|
1390
|
-
async function down$
|
|
1390
|
+
async function down$85(db) {
|
|
1391
1391
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1392
1392
|
for (const tableName of tableNames) {
|
|
1393
1393
|
const table = { name: tableName };
|
|
@@ -1420,10 +1420,10 @@ async function down$84(db) {
|
|
|
1420
1420
|
//#endregion
|
|
1421
1421
|
//#region src/database/migrations/034_published_at_index.ts
|
|
1422
1422
|
var _034_published_at_index_exports = /* @__PURE__ */ __exportAll({
|
|
1423
|
-
down: () => down$
|
|
1424
|
-
up: () => up$
|
|
1423
|
+
down: () => down$84,
|
|
1424
|
+
up: () => up$84
|
|
1425
1425
|
});
|
|
1426
|
-
async function up$
|
|
1426
|
+
async function up$84(db) {
|
|
1427
1427
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1428
1428
|
for (const tableName of tableNames) {
|
|
1429
1429
|
const table = { name: tableName };
|
|
@@ -1433,7 +1433,7 @@ async function up$83(db) {
|
|
|
1433
1433
|
`.execute(db);
|
|
1434
1434
|
}
|
|
1435
1435
|
}
|
|
1436
|
-
async function down$
|
|
1436
|
+
async function down$84(db) {
|
|
1437
1437
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1438
1438
|
for (const tableName of tableNames) {
|
|
1439
1439
|
const table = { name: tableName };
|
|
@@ -1444,15 +1444,15 @@ async function down$83(db) {
|
|
|
1444
1444
|
//#endregion
|
|
1445
1445
|
//#region src/database/migrations/035_backfill_url_patterns.ts
|
|
1446
1446
|
var _035_backfill_url_patterns_exports = /* @__PURE__ */ __exportAll({
|
|
1447
|
-
down: () => down$
|
|
1448
|
-
up: () => up$
|
|
1447
|
+
down: () => down$83,
|
|
1448
|
+
up: () => up$83
|
|
1449
1449
|
});
|
|
1450
1450
|
/**
|
|
1451
1451
|
* Backfill default URL patterns for the built-in posts and pages collections.
|
|
1452
1452
|
*
|
|
1453
1453
|
* Existing rows keep custom patterns; only missing defaults are filled.
|
|
1454
1454
|
*/
|
|
1455
|
-
async function up$
|
|
1455
|
+
async function up$83(db) {
|
|
1456
1456
|
await sql`
|
|
1457
1457
|
UPDATE _dineway_collections
|
|
1458
1458
|
SET url_pattern = '/posts/{slug}'
|
|
@@ -1464,7 +1464,7 @@ async function up$82(db) {
|
|
|
1464
1464
|
WHERE slug = 'pages' AND url_pattern IS NULL
|
|
1465
1465
|
`.execute(db);
|
|
1466
1466
|
}
|
|
1467
|
-
async function down$
|
|
1467
|
+
async function down$83(db) {
|
|
1468
1468
|
await sql`
|
|
1469
1469
|
UPDATE _dineway_collections
|
|
1470
1470
|
SET url_pattern = NULL
|
|
@@ -1480,8 +1480,8 @@ async function down$82(db) {
|
|
|
1480
1480
|
//#endregion
|
|
1481
1481
|
//#region src/database/migrations/036_activity_log.ts
|
|
1482
1482
|
var _036_activity_log_exports = /* @__PURE__ */ __exportAll({
|
|
1483
|
-
down: () => down$
|
|
1484
|
-
up: () => up$
|
|
1483
|
+
down: () => down$82,
|
|
1484
|
+
up: () => up$82
|
|
1485
1485
|
});
|
|
1486
1486
|
/**
|
|
1487
1487
|
* Site Context Engine activity foundation.
|
|
@@ -1490,7 +1490,7 @@ var _036_activity_log_exports = /* @__PURE__ */ __exportAll({
|
|
|
1490
1490
|
* not a request log. Actor IDs intentionally have no foreign key because the
|
|
1491
1491
|
* actor source can be users, API tokens, or a stable system actor.
|
|
1492
1492
|
*/
|
|
1493
|
-
async function up$
|
|
1493
|
+
async function up$82(db) {
|
|
1494
1494
|
await db.schema.createTable("_dineway_activity_log").addColumn("id", "text", (col) => col.primaryKey()).addColumn("actor_type", "text", (col) => col.notNull().check(sql`actor_type in ('user', 'api_token', 'system')`)).addColumn("actor_id", "text", (col) => col.notNull()).addColumn("auth_metadata", "text").addColumn("action_type", "text", (col) => col.notNull()).addColumn("subject_type", "text", (col) => col.notNull()).addColumn("subject_id", "text").addColumn("related_subject_type", "text").addColumn("related_subject_id", "text").addColumn("source_type", "text", (col) => col.check(sql`source_type is null or source_type in ('api_route', 'mcp_tool', 'system', 'plugin', 'unknown')`)).addColumn("source_name", "text").addColumn("result_status", "text", (col) => col.notNull().defaultTo("succeeded").check(sql`result_status in ('succeeded', 'pending', 'failed', 'blocked')`)).addColumn("scope", "text", (col) => col.notNull()).addColumn("summary", "text", (col) => col.notNull()).addColumn("detail", "text").addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).execute();
|
|
1495
1495
|
await db.schema.createIndex("idx_dineway_activity_actor").on("_dineway_activity_log").columns([
|
|
1496
1496
|
"actor_type",
|
|
@@ -1517,15 +1517,15 @@ async function up$81(db) {
|
|
|
1517
1517
|
await db.schema.createIndex("idx_dineway_activity_result_status").on("_dineway_activity_log").columns(["result_status", "created_at"]).execute();
|
|
1518
1518
|
await db.schema.createIndex("idx_dineway_activity_created_at").on("_dineway_activity_log").column("created_at").execute();
|
|
1519
1519
|
}
|
|
1520
|
-
async function down$
|
|
1520
|
+
async function down$82(db) {
|
|
1521
1521
|
await db.schema.dropTable("_dineway_activity_log").execute();
|
|
1522
1522
|
}
|
|
1523
1523
|
|
|
1524
1524
|
//#endregion
|
|
1525
1525
|
//#region src/database/migrations/037_context_entries.ts
|
|
1526
1526
|
var _037_context_entries_exports = /* @__PURE__ */ __exportAll({
|
|
1527
|
-
down: () => down$
|
|
1528
|
-
up: () => up$
|
|
1527
|
+
down: () => down$81,
|
|
1528
|
+
up: () => up$81
|
|
1529
1529
|
});
|
|
1530
1530
|
const CONTEXT_TYPE_SQL = [
|
|
1531
1531
|
"brand_voice",
|
|
@@ -1550,7 +1550,7 @@ const CONTEXT_TYPE_SQL = [
|
|
|
1550
1550
|
* marking old entries non-current and linking replacements through
|
|
1551
1551
|
* `supersedes_id`.
|
|
1552
1552
|
*/
|
|
1553
|
-
async function up$
|
|
1553
|
+
async function up$81(db) {
|
|
1554
1554
|
await db.schema.createTable("_dineway_context_entries").addColumn("id", "text", (col) => col.primaryKey()).addColumn("scope", "text", (col) => col.notNull()).addColumn("context_type", "text", (col) => col.notNull().check(sql`context_type in (${sql.raw(CONTEXT_TYPE_SQL)})`)).addColumn("title", "text", (col) => col.notNull()).addColumn("body", "text", (col) => col.notNull()).addColumn("policy_key", "text").addColumn("source_activity_id", "text").addColumn("created_by_actor_type", "text", (col) => col.notNull().check(sql`created_by_actor_type in ('user', 'api_token', 'system')`)).addColumn("created_by_actor_id", "text", (col) => col.notNull()).addColumn("created_auth_metadata", "text").addColumn("supersedes_id", "text").addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("is_current", "integer", (col) => col.notNull().defaultTo(1).check(sql`is_current in (0, 1)`)).addColumn("valid_until", "text").addColumn("reviewed_at", "text").addColumn("reviewed_by_actor_type", "text", (col) => col.check(sql`reviewed_by_actor_type is null or reviewed_by_actor_type in ('user', 'api_token', 'system')`)).addColumn("reviewed_by_actor_id", "text").addColumn("review_note", "text").addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addForeignKeyConstraint("fk_dineway_context_source_activity", ["source_activity_id"], "_dineway_activity_log", ["id"], (cb) => cb.onDelete("set null")).addForeignKeyConstraint("fk_dineway_context_supersedes", ["supersedes_id"], "_dineway_context_entries", ["id"], (cb) => cb.onDelete("set null")).execute();
|
|
1555
1555
|
await db.schema.createTable("_dineway_context_tags").addColumn("context_entry_id", "text", (col) => col.notNull()).addColumn("tag", "text", (col) => col.notNull()).addPrimaryKeyConstraint("pk_dineway_context_tags", ["context_entry_id", "tag"]).addForeignKeyConstraint("fk_dineway_context_tags_entry", ["context_entry_id"], "_dineway_context_entries", ["id"], (cb) => cb.onDelete("cascade")).execute();
|
|
1556
1556
|
await db.schema.createIndex("idx_dineway_context_scope_current").on("_dineway_context_entries").columns([
|
|
@@ -1575,7 +1575,7 @@ async function up$80(db) {
|
|
|
1575
1575
|
await db.schema.createIndex("idx_dineway_context_created_at").on("_dineway_context_entries").column("created_at").execute();
|
|
1576
1576
|
await db.schema.createIndex("idx_dineway_context_tags_tag").on("_dineway_context_tags").columns(["tag", "context_entry_id"]).execute();
|
|
1577
1577
|
}
|
|
1578
|
-
async function down$
|
|
1578
|
+
async function down$81(db) {
|
|
1579
1579
|
await db.schema.dropTable("_dineway_context_tags").execute();
|
|
1580
1580
|
await db.schema.dropTable("_dineway_context_entries").execute();
|
|
1581
1581
|
}
|
|
@@ -1583,8 +1583,8 @@ async function down$80(db) {
|
|
|
1583
1583
|
//#endregion
|
|
1584
1584
|
//#region src/database/migrations/038_review_requests.ts
|
|
1585
1585
|
var _038_review_requests_exports = /* @__PURE__ */ __exportAll({
|
|
1586
|
-
down: () => down$
|
|
1587
|
-
up: () => up$
|
|
1586
|
+
down: () => down$80,
|
|
1587
|
+
up: () => up$80
|
|
1588
1588
|
});
|
|
1589
1589
|
/**
|
|
1590
1590
|
* Lightweight content review requests for Phase 5a.
|
|
@@ -1592,7 +1592,7 @@ var _038_review_requests_exports = /* @__PURE__ */ __exportAll({
|
|
|
1592
1592
|
* Review requests bind human approval to immutable content revision/action
|
|
1593
1593
|
* identifiers so an approval cannot be reused after the draft or action changes.
|
|
1594
1594
|
*/
|
|
1595
|
-
async function up$
|
|
1595
|
+
async function up$80(db) {
|
|
1596
1596
|
await db.schema.createTable("_dineway_review_requests").addColumn("id", "text", (col) => col.primaryKey()).addColumn("status", "text", (col) => col.notNull().defaultTo("pending").check(sql`status in ('pending', 'approved', 'rejected')`)).addColumn("collection", "text", (col) => col.notNull()).addColumn("entry_id", "text", (col) => col.notNull()).addColumn("scope", "text", (col) => col.notNull()).addColumn("live_revision_id", "text").addColumn("draft_revision_id", "text").addColumn("reviewed_rev", "text", (col) => col.notNull()).addColumn("action_type", "text", (col) => col.notNull()).addColumn("action_hash", "text", (col) => col.notNull()).addColumn("risk_reason", "text").addColumn("review_payload", "text", (col) => col.notNull()).addColumn("requested_by_actor_type", "text", (col) => col.notNull().check(sql`requested_by_actor_type in ('user', 'api_token', 'system')`)).addColumn("requested_by_actor_id", "text", (col) => col.notNull()).addColumn("requested_auth_metadata", "text").addColumn("resolved_by_actor_type", "text", (col) => col.check(sql`resolved_by_actor_type is null or resolved_by_actor_type in ('user', 'api_token', 'system')`)).addColumn("resolved_by_actor_id", "text").addColumn("resolved_auth_metadata", "text").addColumn("review_note", "text").addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("resolved_at", "text").execute();
|
|
1597
1597
|
await db.schema.createIndex("idx_dineway_review_status_created").on("_dineway_review_requests").columns(["status", "created_at"]).execute();
|
|
1598
1598
|
await db.schema.createIndex("idx_dineway_review_target").on("_dineway_review_requests").columns([
|
|
@@ -1613,15 +1613,15 @@ async function up$79(db) {
|
|
|
1613
1613
|
]).execute();
|
|
1614
1614
|
await db.schema.createIndex("idx_dineway_review_resolved_at").on("_dineway_review_requests").column("resolved_at").execute();
|
|
1615
1615
|
}
|
|
1616
|
-
async function down$
|
|
1616
|
+
async function down$80(db) {
|
|
1617
1617
|
await db.schema.dropTable("_dineway_review_requests").execute();
|
|
1618
1618
|
}
|
|
1619
1619
|
|
|
1620
1620
|
//#endregion
|
|
1621
1621
|
//#region src/database/migrations/039_entity_aliases.ts
|
|
1622
1622
|
var _039_entity_aliases_exports = /* @__PURE__ */ __exportAll({
|
|
1623
|
-
down: () => down$
|
|
1624
|
-
up: () => up$
|
|
1623
|
+
down: () => down$79,
|
|
1624
|
+
up: () => up$79
|
|
1625
1625
|
});
|
|
1626
1626
|
const ENTITY_ALIAS_TYPES = [
|
|
1627
1627
|
"content",
|
|
@@ -1636,7 +1636,7 @@ const ENTITY_ALIAS_TYPES = [
|
|
|
1636
1636
|
* This replaces CRMy's PostgreSQL-specific alias arrays with a normalized
|
|
1637
1637
|
* mapping table that works across SQLite/libSQL and PostgreSQL.
|
|
1638
1638
|
*/
|
|
1639
|
-
async function up$
|
|
1639
|
+
async function up$79(db) {
|
|
1640
1640
|
const entityTypesSql = sql.join(ENTITY_ALIAS_TYPES.map((value) => sql.lit(value)), sql`, `);
|
|
1641
1641
|
await db.schema.createTable("_dineway_entity_aliases").addColumn("id", "text", (col) => col.primaryKey()).addColumn("entity_type", "text", (col) => col.notNull().check(sql`entity_type in (${entityTypesSql})`)).addColumn("collection_slug", "text").addColumn("entity_id", "text", (col) => col.notNull()).addColumn("alias", "text", (col) => col.notNull()).addColumn("normalized_alias", "text", (col) => col.notNull()).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).execute();
|
|
1642
1642
|
await db.schema.createIndex("idx_dineway_entity_alias_lookup").on("_dineway_entity_aliases").columns(["entity_type", "normalized_alias"]).execute();
|
|
@@ -1653,15 +1653,15 @@ async function up$78(db) {
|
|
|
1653
1653
|
"normalized_alias"
|
|
1654
1654
|
]).unique().execute();
|
|
1655
1655
|
}
|
|
1656
|
-
async function down$
|
|
1656
|
+
async function down$79(db) {
|
|
1657
1657
|
await db.schema.dropTable("_dineway_entity_aliases").execute();
|
|
1658
1658
|
}
|
|
1659
1659
|
|
|
1660
1660
|
//#endregion
|
|
1661
1661
|
//#region src/database/migrations/040_handoff_snapshots.ts
|
|
1662
1662
|
var _040_handoff_snapshots_exports = /* @__PURE__ */ __exportAll({
|
|
1663
|
-
down: () => down$
|
|
1664
|
-
up: () => up$
|
|
1663
|
+
down: () => down$78,
|
|
1664
|
+
up: () => up$78
|
|
1665
1665
|
});
|
|
1666
1666
|
const ACTOR_TYPES$4 = [
|
|
1667
1667
|
"user",
|
|
@@ -1674,7 +1674,7 @@ const HANDOFF_KINDS = [
|
|
|
1674
1674
|
"assignment"
|
|
1675
1675
|
];
|
|
1676
1676
|
const REFERENCE_TYPES = ["review_request", "assignment"];
|
|
1677
|
-
async function up$
|
|
1677
|
+
async function up$78(db) {
|
|
1678
1678
|
const actorTypesSql = sql.join(ACTOR_TYPES$4.map((value) => sql.lit(value)), sql`, `);
|
|
1679
1679
|
const handoffKindsSql = sql.join(HANDOFF_KINDS.map((value) => sql.lit(value)), sql`, `);
|
|
1680
1680
|
const referenceTypesSql = sql.join(REFERENCE_TYPES.map((value) => sql.lit(value)), sql`, `);
|
|
@@ -1688,15 +1688,15 @@ async function up$77(db) {
|
|
|
1688
1688
|
await db.schema.createIndex("idx_dineway_handoff_kind_created").on("_dineway_handoff_snapshots").columns(["handoff_kind", "created_at"]).execute();
|
|
1689
1689
|
await db.schema.createIndex("idx_dineway_handoff_reference").on("_dineway_handoff_snapshots").columns(["reference_type", "reference_id"]).execute();
|
|
1690
1690
|
}
|
|
1691
|
-
async function down$
|
|
1691
|
+
async function down$78(db) {
|
|
1692
1692
|
await db.schema.dropTable("_dineway_handoff_snapshots").execute();
|
|
1693
1693
|
}
|
|
1694
1694
|
|
|
1695
1695
|
//#endregion
|
|
1696
1696
|
//#region src/database/migrations/041_assignments.ts
|
|
1697
1697
|
var _041_assignments_exports = /* @__PURE__ */ __exportAll({
|
|
1698
|
-
down: () => down$
|
|
1699
|
-
up: () => up$
|
|
1698
|
+
down: () => down$77,
|
|
1699
|
+
up: () => up$77
|
|
1700
1700
|
});
|
|
1701
1701
|
const ACTOR_TYPES$3 = [
|
|
1702
1702
|
"user",
|
|
@@ -1718,7 +1718,7 @@ const ASSIGNMENT_PRIORITIES = [
|
|
|
1718
1718
|
"high",
|
|
1719
1719
|
"urgent"
|
|
1720
1720
|
];
|
|
1721
|
-
async function up$
|
|
1721
|
+
async function up$77(db) {
|
|
1722
1722
|
const actorTypesSql = sql.join(ACTOR_TYPES$3.map((value) => sql.lit(value)), sql`, `);
|
|
1723
1723
|
const statusesSql = sql.join(ASSIGNMENT_STATUSES.map((value) => sql.lit(value)), sql`, `);
|
|
1724
1724
|
const prioritiesSql = sql.join(ASSIGNMENT_PRIORITIES.map((value) => sql.lit(value)), sql`, `);
|
|
@@ -1750,15 +1750,15 @@ async function up$76(db) {
|
|
|
1750
1750
|
await db.schema.createIndex("idx_dineway_assignment_due_at").on("_dineway_assignments").column("due_at").execute();
|
|
1751
1751
|
await db.schema.createIndex("idx_dineway_assignment_handoff").on("_dineway_assignments").column("related_handoff_snapshot_id").execute();
|
|
1752
1752
|
}
|
|
1753
|
-
async function down$
|
|
1753
|
+
async function down$77(db) {
|
|
1754
1754
|
await db.schema.dropTable("_dineway_assignments").execute();
|
|
1755
1755
|
}
|
|
1756
1756
|
|
|
1757
1757
|
//#endregion
|
|
1758
1758
|
//#region src/database/migrations/042_hitl_requests.ts
|
|
1759
1759
|
var _042_hitl_requests_exports = /* @__PURE__ */ __exportAll({
|
|
1760
|
-
down: () => down$
|
|
1761
|
-
up: () => up$
|
|
1760
|
+
down: () => down$76,
|
|
1761
|
+
up: () => up$76
|
|
1762
1762
|
});
|
|
1763
1763
|
const ACTOR_TYPES$2 = [
|
|
1764
1764
|
"user",
|
|
@@ -1776,7 +1776,7 @@ const HITL_PRIORITIES = [
|
|
|
1776
1776
|
"high",
|
|
1777
1777
|
"urgent"
|
|
1778
1778
|
];
|
|
1779
|
-
async function up$
|
|
1779
|
+
async function up$76(db) {
|
|
1780
1780
|
const actorTypesSql = sql.join(ACTOR_TYPES$2.map((value) => sql.lit(value)), sql`, `);
|
|
1781
1781
|
const statusesSql = sql.join(HITL_STATUSES.map((value) => sql.lit(value)), sql`, `);
|
|
1782
1782
|
const prioritiesSql = sql.join(HITL_PRIORITIES.map((value) => sql.lit(value)), sql`, `);
|
|
@@ -1811,7 +1811,7 @@ async function up$75(db) {
|
|
|
1811
1811
|
await db.schema.createIndex("idx_dineway_hitl_sla_due_at").on("_dineway_hitl_requests").column("sla_due_at").execute();
|
|
1812
1812
|
await db.schema.createIndex("idx_dineway_assignment_hitl").on("_dineway_assignments").column("related_hitl_request_id").execute();
|
|
1813
1813
|
}
|
|
1814
|
-
async function down$
|
|
1814
|
+
async function down$76(db) {
|
|
1815
1815
|
await db.schema.dropIndex("idx_dineway_assignment_hitl").execute();
|
|
1816
1816
|
await db.schema.alterTable("_dineway_assignments").dropColumn("related_hitl_request_id").execute();
|
|
1817
1817
|
await db.schema.dropTable("_dineway_hitl_requests").execute();
|
|
@@ -1820,8 +1820,8 @@ async function down$75(db) {
|
|
|
1820
1820
|
//#endregion
|
|
1821
1821
|
//#region src/database/migrations/043_bounded_404_log.ts
|
|
1822
1822
|
var _043_bounded_404_log_exports = /* @__PURE__ */ __exportAll({
|
|
1823
|
-
down: () => down$
|
|
1824
|
-
up: () => up$
|
|
1823
|
+
down: () => down$75,
|
|
1824
|
+
up: () => up$75
|
|
1825
1825
|
});
|
|
1826
1826
|
/**
|
|
1827
1827
|
* Migration: Bounded 404 logging
|
|
@@ -1830,7 +1830,7 @@ var _043_bounded_404_log_exports = /* @__PURE__ */ __exportAll({
|
|
|
1830
1830
|
* Previously every 404 inserted a new row, so a requester could grow the
|
|
1831
1831
|
* table without bound by hitting unique URLs.
|
|
1832
1832
|
*/
|
|
1833
|
-
async function up$
|
|
1833
|
+
async function up$75(db) {
|
|
1834
1834
|
await db.schema.alterTable("_dineway_404_log").addColumn("hits", "integer", (col) => col.notNull().defaultTo(1)).execute();
|
|
1835
1835
|
await db.schema.alterTable("_dineway_404_log").addColumn("last_seen_at", "text").execute();
|
|
1836
1836
|
await sql`
|
|
@@ -1876,7 +1876,7 @@ async function up$74(db) {
|
|
|
1876
1876
|
await db.schema.dropIndex("idx_404_log_path").execute();
|
|
1877
1877
|
await db.schema.createIndex("idx_404_log_last_seen").on("_dineway_404_log").column("last_seen_at").execute();
|
|
1878
1878
|
}
|
|
1879
|
-
async function down$
|
|
1879
|
+
async function down$75(db) {
|
|
1880
1880
|
await db.schema.dropIndex("idx_404_log_last_seen").execute();
|
|
1881
1881
|
await db.schema.dropIndex("idx_404_log_path_unique").execute();
|
|
1882
1882
|
await db.schema.createIndex("idx_404_log_path").on("_dineway_404_log").column("path").execute();
|
|
@@ -1887,21 +1887,21 @@ async function down$74(db) {
|
|
|
1887
1887
|
//#endregion
|
|
1888
1888
|
//#region src/database/migrations/044_credential_algorithm.ts
|
|
1889
1889
|
var _044_credential_algorithm_exports = /* @__PURE__ */ __exportAll({
|
|
1890
|
-
down: () => down$
|
|
1891
|
-
up: () => up$
|
|
1890
|
+
down: () => down$74,
|
|
1891
|
+
up: () => up$74
|
|
1892
1892
|
});
|
|
1893
|
-
async function up$
|
|
1893
|
+
async function up$74(db) {
|
|
1894
1894
|
if (!await columnExists(db, "credentials", "algorithm")) await db.schema.alterTable("credentials").addColumn("algorithm", "integer", (col) => col.notNull().defaultTo(-7)).execute();
|
|
1895
1895
|
}
|
|
1896
|
-
async function down$
|
|
1896
|
+
async function down$74(db) {
|
|
1897
1897
|
if (await columnExists(db, "credentials", "algorithm")) await db.schema.alterTable("credentials").dropColumn("algorithm").execute();
|
|
1898
1898
|
}
|
|
1899
1899
|
|
|
1900
1900
|
//#endregion
|
|
1901
1901
|
//#region src/database/migrations/045_i18n_menus_and_taxonomies.ts
|
|
1902
1902
|
var _045_i18n_menus_and_taxonomies_exports = /* @__PURE__ */ __exportAll({
|
|
1903
|
-
down: () => down$
|
|
1904
|
-
up: () => up$
|
|
1903
|
+
down: () => down$73,
|
|
1904
|
+
up: () => up$73
|
|
1905
1905
|
});
|
|
1906
1906
|
/**
|
|
1907
1907
|
* i18n for menus + taxonomies. Adds `locale` + `translation_group` to system
|
|
@@ -1912,7 +1912,7 @@ var _045_i18n_menus_and_taxonomies_exports = /* @__PURE__ */ __exportAll({
|
|
|
1912
1912
|
function getDefaultLocale$1() {
|
|
1913
1913
|
return getI18nConfig()?.defaultLocale ?? "en";
|
|
1914
1914
|
}
|
|
1915
|
-
async function up$
|
|
1915
|
+
async function up$73(db) {
|
|
1916
1916
|
const defaultLocale = getDefaultLocale$1();
|
|
1917
1917
|
if (isSqlite(db)) {
|
|
1918
1918
|
await sql.raw(`PRAGMA foreign_keys = OFF`).execute(db);
|
|
@@ -2103,7 +2103,7 @@ async function assertSingleLocale$1(db, defaultLocale) {
|
|
|
2103
2103
|
if (count > 0) throw new Error(`Cannot revert migration 045_i18n_menus_and_taxonomies: ${count} row(s) in "${table}" use a non-default locale (defaultLocale="${defaultLocale}"). Reverting would drop them silently. Export translations first (or delete them) and re-run the rollback. See packages/core/src/database/migrations/045_i18n_menus_and_taxonomies.ts.`);
|
|
2104
2104
|
}
|
|
2105
2105
|
}
|
|
2106
|
-
async function down$
|
|
2106
|
+
async function down$73(db) {
|
|
2107
2107
|
const defaultLocale = getDefaultLocale$1();
|
|
2108
2108
|
await assertSingleLocale$1(db, defaultLocale);
|
|
2109
2109
|
const widenedTables = [
|
|
@@ -2197,21 +2197,21 @@ async function rebuildTaxonomyDefsDown(db) {
|
|
|
2197
2197
|
//#endregion
|
|
2198
2198
|
//#region src/database/migrations/046_astro_sessions.ts
|
|
2199
2199
|
var _046_astro_sessions_exports = /* @__PURE__ */ __exportAll({
|
|
2200
|
-
down: () => down$
|
|
2201
|
-
up: () => up$
|
|
2200
|
+
down: () => down$72,
|
|
2201
|
+
up: () => up$72
|
|
2202
2202
|
});
|
|
2203
|
-
async function up$
|
|
2203
|
+
async function up$72(db) {
|
|
2204
2204
|
await db.schema.createTable("_dineway_sessions").ifNotExists().addColumn("id", "text", (col) => col.primaryKey()).addColumn("value", "text", (col) => col.notNull()).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).execute();
|
|
2205
2205
|
}
|
|
2206
|
-
async function down$
|
|
2206
|
+
async function down$72(db) {
|
|
2207
2207
|
await db.schema.dropTable("_dineway_sessions").ifExists().execute();
|
|
2208
2208
|
}
|
|
2209
2209
|
|
|
2210
2210
|
//#endregion
|
|
2211
2211
|
//#region src/database/migrations/047_content_locale_list_index.ts
|
|
2212
2212
|
var _047_content_locale_list_index_exports = /* @__PURE__ */ __exportAll({
|
|
2213
|
-
down: () => down$
|
|
2214
|
-
up: () => up$
|
|
2213
|
+
down: () => down$71,
|
|
2214
|
+
up: () => up$71
|
|
2215
2215
|
});
|
|
2216
2216
|
/**
|
|
2217
2217
|
* Add locale-aware composite indexes for content list queries.
|
|
@@ -2221,7 +2221,7 @@ var _047_content_locale_list_index_exports = /* @__PURE__ */ __exportAll({
|
|
|
2221
2221
|
* path but omit locale, so locale-filtered lists cannot be served by one index
|
|
2222
2222
|
* on large tables.
|
|
2223
2223
|
*/
|
|
2224
|
-
async function up$
|
|
2224
|
+
async function up$71(db) {
|
|
2225
2225
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
2226
2226
|
for (const tableName of tableNames) {
|
|
2227
2227
|
await sql`
|
|
@@ -2234,7 +2234,7 @@ async function up$70(db) {
|
|
|
2234
2234
|
`.execute(db);
|
|
2235
2235
|
}
|
|
2236
2236
|
}
|
|
2237
|
-
async function down$
|
|
2237
|
+
async function down$71(db) {
|
|
2238
2238
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
2239
2239
|
for (const tableName of tableNames) {
|
|
2240
2240
|
await sql`DROP INDEX IF EXISTS ${sql.ref(contentLocaleUpdatedIndexName(tableName))}`.execute(db);
|
|
@@ -2245,8 +2245,8 @@ async function down$70(db) {
|
|
|
2245
2245
|
//#endregion
|
|
2246
2246
|
//#region src/database/migrations/048_byline_i18n.ts
|
|
2247
2247
|
var _048_byline_i18n_exports = /* @__PURE__ */ __exportAll({
|
|
2248
|
-
down: () => down$
|
|
2249
|
-
up: () => up$
|
|
2248
|
+
down: () => down$70,
|
|
2249
|
+
up: () => up$70
|
|
2250
2250
|
});
|
|
2251
2251
|
/**
|
|
2252
2252
|
* Adds row-per-locale bylines.
|
|
@@ -2259,7 +2259,7 @@ var _048_byline_i18n_exports = /* @__PURE__ */ __exportAll({
|
|
|
2259
2259
|
function getDefaultLocale() {
|
|
2260
2260
|
return getI18nConfig()?.defaultLocale ?? "en";
|
|
2261
2261
|
}
|
|
2262
|
-
async function up$
|
|
2262
|
+
async function up$70(db) {
|
|
2263
2263
|
const defaultLocale = getDefaultLocale();
|
|
2264
2264
|
if (isSqlite(db)) {
|
|
2265
2265
|
await rebuildContentBylines(db);
|
|
@@ -2418,7 +2418,7 @@ async function assertSingleLocale(db, defaultLocale) {
|
|
|
2418
2418
|
const count = Number(result.rows[0]?.count ?? 0);
|
|
2419
2419
|
if (count > 0) throw new Error(`Cannot revert migration 048_byline_i18n: ${count} row(s) in "_dineway_bylines" use a non-default locale (defaultLocale="${defaultLocale}").`);
|
|
2420
2420
|
}
|
|
2421
|
-
async function down$
|
|
2421
|
+
async function down$70(db) {
|
|
2422
2422
|
const defaultLocale = getDefaultLocale();
|
|
2423
2423
|
await assertSingleLocale(db, defaultLocale);
|
|
2424
2424
|
await assertContentBylinesResolve(db, defaultLocale);
|
|
@@ -2540,10 +2540,10 @@ async function restoreContentBylinesFk(db) {
|
|
|
2540
2540
|
//#endregion
|
|
2541
2541
|
//#region src/database/migrations/049_byline_fields.ts
|
|
2542
2542
|
var _049_byline_fields_exports = /* @__PURE__ */ __exportAll({
|
|
2543
|
-
down: () => down$
|
|
2544
|
-
up: () => up$
|
|
2543
|
+
down: () => down$69,
|
|
2544
|
+
up: () => up$69
|
|
2545
2545
|
});
|
|
2546
|
-
async function up$
|
|
2546
|
+
async function up$69(db) {
|
|
2547
2547
|
await db.schema.createTable("_dineway_byline_fields").ifNotExists().addColumn("id", "text", (col) => col.primaryKey()).addColumn("slug", "text", (col) => col.notNull().unique()).addColumn("label", "text", (col) => col.notNull()).addColumn("type", "text", (col) => col.notNull()).addColumn("required", "integer", (col) => col.notNull().defaultTo(0)).addColumn("translatable", "integer", (col) => col.notNull().defaultTo(1)).addColumn("validation", "text").addColumn("sort_order", "integer", (col) => col.notNull().defaultTo(0)).addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).execute();
|
|
2548
2548
|
await db.schema.createIndex("idx__dineway_byline_fields_sort_order").ifNotExists().on("_dineway_byline_fields").column("sort_order").execute();
|
|
2549
2549
|
await db.schema.createTable("_dineway_byline_field_values").ifNotExists().addColumn("byline_id", "text", (col) => col.notNull().references("_dineway_bylines.id").onDelete("cascade")).addColumn("field_id", "text", (col) => col.notNull().references("_dineway_byline_fields.id").onDelete("cascade")).addColumn("value", "text").addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addPrimaryKeyConstraint("_dineway_byline_field_values_pk", ["byline_id", "field_id"]).execute();
|
|
@@ -2557,7 +2557,7 @@ async function up$68(db) {
|
|
|
2557
2557
|
ON CONFLICT (name) DO NOTHING
|
|
2558
2558
|
`.execute(db);
|
|
2559
2559
|
}
|
|
2560
|
-
async function down$
|
|
2560
|
+
async function down$69(db) {
|
|
2561
2561
|
await db.schema.dropTable("_dineway_byline_field_group_values").ifExists().execute();
|
|
2562
2562
|
await db.schema.dropTable("_dineway_byline_field_values").ifExists().execute();
|
|
2563
2563
|
await db.schema.dropTable("_dineway_byline_fields").ifExists().execute();
|
|
@@ -2567,8 +2567,8 @@ async function down$68(db) {
|
|
|
2567
2567
|
//#endregion
|
|
2568
2568
|
//#region src/database/migrations/050_content_references.ts
|
|
2569
2569
|
var _050_content_references_exports = /* @__PURE__ */ __exportAll({
|
|
2570
|
-
down: () => down$
|
|
2571
|
-
up: () => up$
|
|
2570
|
+
down: () => down$68,
|
|
2571
|
+
up: () => up$68
|
|
2572
2572
|
});
|
|
2573
2573
|
/**
|
|
2574
2574
|
* Content references.
|
|
@@ -2577,7 +2577,7 @@ var _050_content_references_exports = /* @__PURE__ */ __exportAll({
|
|
|
2577
2577
|
* with one localized row per locale. `_dineway_content_references` stores
|
|
2578
2578
|
* parent -> child edges keyed by translation groups so edges are locale-agnostic.
|
|
2579
2579
|
*/
|
|
2580
|
-
async function up$
|
|
2580
|
+
async function up$68(db) {
|
|
2581
2581
|
const defaultLocale = getI18nConfig()?.defaultLocale ?? "en";
|
|
2582
2582
|
await db.schema.createTable("_dineway_relations").ifNotExists().addColumn("id", "text", (col) => col.primaryKey()).addColumn("name", "text", (col) => col.notNull()).addColumn("parent_collection", "text", (col) => col.notNull()).addColumn("child_collection", "text", (col) => col.notNull()).addColumn("parent_label", "text", (col) => col.notNull()).addColumn("child_label", "text", (col) => col.notNull()).addColumn("locale", "text", (col) => col.notNull().defaultTo(defaultLocale)).addColumn("translation_group", "text", (col) => col.notNull()).addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addUniqueConstraint("_dineway_relations_name_locale_unique", ["name", "locale"]).execute();
|
|
2583
2583
|
await db.schema.createIndex("idx__dineway_relations_locale").ifNotExists().on("_dineway_relations").column("locale").execute();
|
|
@@ -2598,7 +2598,7 @@ async function up$67(db) {
|
|
|
2598
2598
|
await db.schema.createIndex("idx__dineway_content_references_child").ifNotExists().on("_dineway_content_references").columns(["child_group", "relation_group"]).execute();
|
|
2599
2599
|
await db.schema.createIndex("idx__dineway_content_references_relation").ifNotExists().on("_dineway_content_references").column("relation_group").execute();
|
|
2600
2600
|
}
|
|
2601
|
-
async function down$
|
|
2601
|
+
async function down$68(db) {
|
|
2602
2602
|
await db.schema.dropTable("_dineway_content_references").ifExists().execute();
|
|
2603
2603
|
await db.schema.dropTable("_dineway_relations").ifExists().execute();
|
|
2604
2604
|
}
|
|
@@ -2606,8 +2606,8 @@ async function down$67(db) {
|
|
|
2606
2606
|
//#endregion
|
|
2607
2607
|
//#region src/database/migrations/051_dineway_web_plugin.ts
|
|
2608
2608
|
var _051_dineway_web_plugin_exports = /* @__PURE__ */ __exportAll({
|
|
2609
|
-
down: () => down$
|
|
2610
|
-
up: () => up$
|
|
2609
|
+
down: () => down$67,
|
|
2610
|
+
up: () => up$67
|
|
2611
2611
|
});
|
|
2612
2612
|
const SESSION_STATUSES = [
|
|
2613
2613
|
"active",
|
|
@@ -2642,7 +2642,7 @@ const HANDOFF_AUDIT_EVENTS = [
|
|
|
2642
2642
|
function enumValues(values) {
|
|
2643
2643
|
return sql.join(values.map((value) => sql.lit(value)), sql`, `);
|
|
2644
2644
|
}
|
|
2645
|
-
async function up$
|
|
2645
|
+
async function up$67(db) {
|
|
2646
2646
|
const sessionStatuses = enumValues(SESSION_STATUSES);
|
|
2647
2647
|
const onboardingStatuses = enumValues(ONBOARDING_STATUSES);
|
|
2648
2648
|
const checkoutStatuses = enumValues(CHECKOUT_STATUSES);
|
|
@@ -2685,7 +2685,7 @@ async function up$66(db) {
|
|
|
2685
2685
|
await db.schema.createIndex("idx_dineway_web_handoff_audit_handoff").ifNotExists().on("_dineway_dineway_web_handoff_audit").column("handoff_id").execute();
|
|
2686
2686
|
await db.schema.createIndex("idx_dineway_web_handoff_audit_event").ifNotExists().on("_dineway_dineway_web_handoff_audit").column("event").execute();
|
|
2687
2687
|
}
|
|
2688
|
-
async function down$
|
|
2688
|
+
async function down$67(db) {
|
|
2689
2689
|
await db.schema.dropTable("_dineway_dineway_web_handoff_audit").ifExists().execute();
|
|
2690
2690
|
await db.schema.dropTable("_dineway_dineway_web_handoffs").ifExists().execute();
|
|
2691
2691
|
await db.schema.dropTable("_dineway_dineway_web_sites_projections").ifExists().execute();
|
|
@@ -2700,19 +2700,19 @@ async function down$66(db) {
|
|
|
2700
2700
|
//#endregion
|
|
2701
2701
|
//#region src/database/migrations/052_taxonomies_name_locale_index.ts
|
|
2702
2702
|
var _052_taxonomies_name_locale_index_exports = /* @__PURE__ */ __exportAll({
|
|
2703
|
-
down: () => down$
|
|
2704
|
-
up: () => up$
|
|
2703
|
+
down: () => down$66,
|
|
2704
|
+
up: () => up$66
|
|
2705
2705
|
});
|
|
2706
2706
|
/**
|
|
2707
2707
|
* Add a composite taxonomy lookup index for queries that filter by name and locale.
|
|
2708
2708
|
* The composite's leftmost prefix covers name-only lookups, so it replaces the
|
|
2709
2709
|
* older single-column name index while preserving the locale-only index.
|
|
2710
2710
|
*/
|
|
2711
|
-
async function up$
|
|
2711
|
+
async function up$66(db) {
|
|
2712
2712
|
await db.schema.createIndex("idx_taxonomies_name_locale").ifNotExists().on("taxonomies").columns(["name", "locale"]).execute();
|
|
2713
2713
|
await db.schema.dropIndex("idx_taxonomies_name").ifExists().execute();
|
|
2714
2714
|
}
|
|
2715
|
-
async function down$
|
|
2715
|
+
async function down$66(db) {
|
|
2716
2716
|
await db.schema.createIndex("idx_taxonomies_name").ifNotExists().on("taxonomies").column("name").execute();
|
|
2717
2717
|
await db.schema.dropIndex("idx_taxonomies_name_locale").ifExists().execute();
|
|
2718
2718
|
}
|
|
@@ -2720,8 +2720,8 @@ async function down$65(db) {
|
|
|
2720
2720
|
//#endregion
|
|
2721
2721
|
//#region src/database/migrations/053_restore_content_taxonomies_term_index.ts
|
|
2722
2722
|
var _053_restore_content_taxonomies_term_index_exports = /* @__PURE__ */ __exportAll({
|
|
2723
|
-
down: () => down$
|
|
2724
|
-
up: () => up$
|
|
2723
|
+
down: () => down$65,
|
|
2724
|
+
up: () => up$65
|
|
2725
2725
|
});
|
|
2726
2726
|
/**
|
|
2727
2727
|
* Restore the reverse lookup index on content taxonomy assignments.
|
|
@@ -2730,16 +2730,16 @@ var _053_restore_content_taxonomies_term_index_exports = /* @__PURE__ */ __expor
|
|
|
2730
2730
|
* covers upgraded SQLite databases that already recorded the table rebuild but
|
|
2731
2731
|
* ended up missing only this index.
|
|
2732
2732
|
*/
|
|
2733
|
-
async function up$
|
|
2733
|
+
async function up$65(db) {
|
|
2734
2734
|
await db.schema.createIndex("idx_content_taxonomies_term").ifNotExists().on("content_taxonomies").column("taxonomy_id").execute();
|
|
2735
2735
|
}
|
|
2736
|
-
async function down$
|
|
2736
|
+
async function down$65(db) {}
|
|
2737
2737
|
|
|
2738
2738
|
//#endregion
|
|
2739
2739
|
//#region src/database/migrations/054_restore_taxonomy_parent_index.ts
|
|
2740
2740
|
var _054_restore_taxonomy_parent_index_exports = /* @__PURE__ */ __exportAll({
|
|
2741
|
-
down: () => down$
|
|
2742
|
-
up: () => up$
|
|
2741
|
+
down: () => down$64,
|
|
2742
|
+
up: () => up$64
|
|
2743
2743
|
});
|
|
2744
2744
|
/**
|
|
2745
2745
|
* Restore the parent lookup index on hierarchical taxonomy terms.
|
|
@@ -2748,16 +2748,16 @@ var _054_restore_taxonomy_parent_index_exports = /* @__PURE__ */ __exportAll({
|
|
|
2748
2748
|
* could drop it on upgraded databases. Fresh installs recreate it in the
|
|
2749
2749
|
* rebuild path; this forward repair covers already-migrated databases.
|
|
2750
2750
|
*/
|
|
2751
|
-
async function up$
|
|
2751
|
+
async function up$64(db) {
|
|
2752
2752
|
await db.schema.createIndex("idx_taxonomies_parent").ifNotExists().on("taxonomies").column("parent_id").execute();
|
|
2753
2753
|
}
|
|
2754
|
-
async function down$
|
|
2754
|
+
async function down$64(db) {}
|
|
2755
2755
|
|
|
2756
2756
|
//#endregion
|
|
2757
2757
|
//#region src/database/migrations/055_taxonomy_parent_group.ts
|
|
2758
2758
|
var _055_taxonomy_parent_group_exports = /* @__PURE__ */ __exportAll({
|
|
2759
|
-
down: () => down$
|
|
2760
|
-
up: () => up$
|
|
2759
|
+
down: () => down$63,
|
|
2760
|
+
up: () => up$63
|
|
2761
2761
|
});
|
|
2762
2762
|
/**
|
|
2763
2763
|
* Store the parent's `translation_group` in `taxonomies.parent_id` instead of a
|
|
@@ -2772,7 +2772,7 @@ var _055_taxonomy_parent_group_exports = /* @__PURE__ */ __exportAll({
|
|
|
2772
2772
|
* anchor row's id. Only rewrite when that anchor row exists; otherwise keep the
|
|
2773
2773
|
* existing row id rather than writing a dangling FK value.
|
|
2774
2774
|
*/
|
|
2775
|
-
async function up$
|
|
2775
|
+
async function up$63(db) {
|
|
2776
2776
|
await sql`
|
|
2777
2777
|
UPDATE taxonomies
|
|
2778
2778
|
SET parent_id = (
|
|
@@ -2799,7 +2799,7 @@ async function up$62(db) {
|
|
|
2799
2799
|
* Rows with no same-locale parent are left as-is so rollback does not silently
|
|
2800
2800
|
* detach a subtree.
|
|
2801
2801
|
*/
|
|
2802
|
-
async function down$
|
|
2802
|
+
async function down$63(db) {
|
|
2803
2803
|
await sql`
|
|
2804
2804
|
UPDATE taxonomies
|
|
2805
2805
|
SET parent_id = COALESCE(
|
|
@@ -2818,8 +2818,8 @@ async function down$62(db) {
|
|
|
2818
2818
|
//#endregion
|
|
2819
2819
|
//#region src/database/migrations/056_media_usage_index.ts
|
|
2820
2820
|
var _056_media_usage_index_exports = /* @__PURE__ */ __exportAll({
|
|
2821
|
-
down: () => down$
|
|
2822
|
-
up: () => up$
|
|
2821
|
+
down: () => down$62,
|
|
2822
|
+
up: () => up$62
|
|
2823
2823
|
});
|
|
2824
2824
|
/**
|
|
2825
2825
|
* Internal media usage projection tables.
|
|
@@ -2828,7 +2828,7 @@ var _056_media_usage_index_exports = /* @__PURE__ */ __exportAll({
|
|
|
2828
2828
|
* imports, and no content-table scans. Production rows are introduced by later
|
|
2829
2829
|
* phases once the central snapshot/indexer path is reviewed.
|
|
2830
2830
|
*/
|
|
2831
|
-
async function up$
|
|
2831
|
+
async function up$62(db) {
|
|
2832
2832
|
await db.schema.createTable("_dineway_media_usage_sources").ifNotExists().addColumn("source_key", "text", (col) => col.primaryKey()).addColumn("source_type", "text", (col) => col.notNull()).addColumn("collection_slug", "text").addColumn("content_id", "text").addColumn("source_variant", "text", (col) => col.notNull()).addColumn("locale", "text").addColumn("translation_group", "text").addColumn("content_slug", "text").addColumn("content_title", "text").addColumn("content_status", "text").addColumn("content_scheduled_at", "text").addColumn("content_deleted_at", "text").addColumn("revision_id", "text").addColumn("current_generation", "text", (col) => col.notNull()).addColumn("schema_version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("indexed_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).execute();
|
|
2833
2833
|
await db.schema.createIndex("idx__dineway_media_usage_sources_content").ifNotExists().on("_dineway_media_usage_sources").columns([
|
|
2834
2834
|
"source_type",
|
|
@@ -2850,7 +2850,7 @@ async function up$61(db) {
|
|
|
2850
2850
|
await db.schema.createIndex("idx__dineway_media_usage_provider_asset").ifNotExists().on("_dineway_media_usage").columns(["provider", "provider_asset_id"]).execute();
|
|
2851
2851
|
await db.schema.createIndex("idx__dineway_media_usage_source_generation").ifNotExists().on("_dineway_media_usage").columns(["source_key", "generation"]).execute();
|
|
2852
2852
|
}
|
|
2853
|
-
async function down$
|
|
2853
|
+
async function down$62(db) {
|
|
2854
2854
|
await db.schema.dropTable("_dineway_media_usage").ifExists().execute();
|
|
2855
2855
|
await db.schema.dropTable("_dineway_media_usage_sources").ifExists().execute();
|
|
2856
2856
|
}
|
|
@@ -2858,8 +2858,8 @@ async function down$61(db) {
|
|
|
2858
2858
|
//#endregion
|
|
2859
2859
|
//#region src/database/migrations/057_media_usage_index_status.ts
|
|
2860
2860
|
var _057_media_usage_index_status_exports = /* @__PURE__ */ __exportAll({
|
|
2861
|
-
down: () => down$
|
|
2862
|
-
up: () => up$
|
|
2861
|
+
down: () => down$61,
|
|
2862
|
+
up: () => up$61
|
|
2863
2863
|
});
|
|
2864
2864
|
const SOURCE_TABLE = "_dineway_media_usage_sources";
|
|
2865
2865
|
const DUPLICATE_COLUMN_RE = /(?:duplicate column|column .* already exists|already exists.*column)/i;
|
|
@@ -2869,7 +2869,7 @@ const DUPLICATE_COLUMN_RE = /(?:duplicate column|column .* already exists|alread
|
|
|
2869
2869
|
* DDL-only by design: adds source metadata and adapter-scope status tracking
|
|
2870
2870
|
* without scanning content tables or importing runtime code.
|
|
2871
2871
|
*/
|
|
2872
|
-
async function up$
|
|
2872
|
+
async function up$61(db) {
|
|
2873
2873
|
await addSourceMetadataColumns(db);
|
|
2874
2874
|
await db.schema.createTable("_dineway_media_usage_index_status").ifNotExists().addColumn("adapter_id", "text", (col) => col.notNull()).addColumn("scope_type", "text", (col) => col.notNull()).addColumn("scope_key", "text", (col) => col.notNull()).addColumn("status", "text", (col) => col.notNull()).addColumn("schema_version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("started_at", "text").addColumn("completed_at", "text").addColumn("cursor", "text").addColumn("indexed_source_count", "integer", (col) => col.notNull().defaultTo(0)).addColumn("failed_source_count", "integer", (col) => col.notNull().defaultTo(0)).addColumn("last_error_code", "text").addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addPrimaryKeyConstraint("_dineway_media_usage_index_status_pk", [
|
|
2875
2875
|
"adapter_id",
|
|
@@ -2884,7 +2884,7 @@ async function up$60(db) {
|
|
|
2884
2884
|
await db.schema.createIndex("idx__dineway_media_usage_sources_fingerprint").ifNotExists().on("_dineway_media_usage_sources").column("source_fingerprint").execute();
|
|
2885
2885
|
await db.schema.createIndex("idx__dineway_media_usage_index_status_status").ifNotExists().on("_dineway_media_usage_index_status").columns(["adapter_id", "status"]).execute();
|
|
2886
2886
|
}
|
|
2887
|
-
async function down$
|
|
2887
|
+
async function down$61(db) {
|
|
2888
2888
|
await db.schema.dropIndex("idx__dineway_media_usage_index_status_status").ifExists().execute();
|
|
2889
2889
|
await db.schema.dropIndex("idx__dineway_media_usage_sources_fingerprint").ifExists().execute();
|
|
2890
2890
|
await db.schema.dropIndex("idx__dineway_media_usage_sources_completeness").ifExists().execute();
|
|
@@ -2940,10 +2940,10 @@ async function dropSourceMetadataColumns(db) {
|
|
|
2940
2940
|
//#endregion
|
|
2941
2941
|
//#region src/database/migrations/058_comment_reactions.ts
|
|
2942
2942
|
var _058_comment_reactions_exports = /* @__PURE__ */ __exportAll({
|
|
2943
|
-
down: () => down$
|
|
2944
|
-
up: () => up$
|
|
2943
|
+
down: () => down$60,
|
|
2944
|
+
up: () => up$60
|
|
2945
2945
|
});
|
|
2946
|
-
async function up$
|
|
2946
|
+
async function up$60(db) {
|
|
2947
2947
|
await db.schema.createTable("_dineway_comment_reactions").addColumn("id", "text", (col) => col.primaryKey()).addColumn("comment_id", "text", (col) => col.notNull().references("_dineway_comments.id").onDelete("cascade")).addColumn("reaction", "text", (col) => col.notNull().defaultTo("like")).addColumn("voter_hash", "text", (col) => col.notNull()).addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp$1(db))).execute();
|
|
2948
2948
|
await db.schema.createIndex("idx_dineway_comment_reactions_unique").on("_dineway_comment_reactions").columns([
|
|
2949
2949
|
"comment_id",
|
|
@@ -2953,15 +2953,15 @@ async function up$59(db) {
|
|
|
2953
2953
|
await db.schema.createIndex("idx_dineway_comment_reactions_comment_id").on("_dineway_comment_reactions").column("comment_id").execute();
|
|
2954
2954
|
await db.schema.createIndex("idx_dineway_comment_reactions_voter_recent").on("_dineway_comment_reactions").columns(["voter_hash", "created_at"]).execute();
|
|
2955
2955
|
}
|
|
2956
|
-
async function down$
|
|
2956
|
+
async function down$60(db) {
|
|
2957
2957
|
await db.schema.dropTable("_dineway_comment_reactions").execute();
|
|
2958
2958
|
}
|
|
2959
2959
|
|
|
2960
2960
|
//#endregion
|
|
2961
2961
|
//#region src/database/migrations/059_hitl_executions.ts
|
|
2962
2962
|
var _059_hitl_executions_exports = /* @__PURE__ */ __exportAll({
|
|
2963
|
-
down: () => down$
|
|
2964
|
-
up: () => up$
|
|
2963
|
+
down: () => down$59,
|
|
2964
|
+
up: () => up$59
|
|
2965
2965
|
});
|
|
2966
2966
|
const ACTOR_TYPES$1 = [
|
|
2967
2967
|
"user",
|
|
@@ -2975,7 +2975,7 @@ const EXECUTION_STATUSES = [
|
|
|
2975
2975
|
"failed",
|
|
2976
2976
|
"indeterminate"
|
|
2977
2977
|
];
|
|
2978
|
-
async function up$
|
|
2978
|
+
async function up$59(db) {
|
|
2979
2979
|
const actorTypesSql = sql.join(ACTOR_TYPES$1.map((value) => sql.lit(value)), sql`, `);
|
|
2980
2980
|
const reviewModesSql = sql.join(REVIEW_MODES.map((value) => sql.lit(value)), sql`, `);
|
|
2981
2981
|
const statusesSql = sql.join(EXECUTION_STATUSES.map((value) => sql.lit(value)), sql`, `);
|
|
@@ -3000,31 +3000,31 @@ async function up$58(db) {
|
|
|
3000
3000
|
"created_at"
|
|
3001
3001
|
]).execute();
|
|
3002
3002
|
}
|
|
3003
|
-
async function down$
|
|
3003
|
+
async function down$59(db) {
|
|
3004
3004
|
await db.schema.dropTable("_dineway_hitl_executions").ifExists().execute();
|
|
3005
3005
|
}
|
|
3006
3006
|
|
|
3007
3007
|
//#endregion
|
|
3008
3008
|
//#region src/database/migrations/060_plugin_secrets.ts
|
|
3009
3009
|
var _060_plugin_secrets_exports = /* @__PURE__ */ __exportAll({
|
|
3010
|
-
down: () => down$
|
|
3011
|
-
up: () => up$
|
|
3010
|
+
down: () => down$58,
|
|
3011
|
+
up: () => up$58
|
|
3012
3012
|
});
|
|
3013
|
-
async function up$
|
|
3013
|
+
async function up$58(db) {
|
|
3014
3014
|
await db.schema.createTable("_dineway_plugin_secrets").addColumn("plugin_id", "text", (col) => col.notNull()).addColumn("secret_name", "text", (col) => col.notNull()).addColumn("encryption_version", "integer", (col) => col.notNull()).addColumn("key_id", "text", (col) => col.notNull()).addColumn("nonce", "text", (col) => col.notNull()).addColumn("ciphertext", "text", (col) => col.notNull()).addColumn("fingerprint", "text", (col) => col.notNull()).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addPrimaryKeyConstraint("pk_dineway_plugin_secrets", ["plugin_id", "secret_name"]).execute();
|
|
3015
3015
|
await db.schema.createIndex("idx_dineway_plugin_secrets_plugin_updated").on("_dineway_plugin_secrets").columns(["plugin_id", "updated_at"]).execute();
|
|
3016
3016
|
}
|
|
3017
|
-
async function down$
|
|
3017
|
+
async function down$58(db) {
|
|
3018
3018
|
await db.schema.dropTable("_dineway_plugin_secrets").execute();
|
|
3019
3019
|
}
|
|
3020
3020
|
|
|
3021
3021
|
//#endregion
|
|
3022
3022
|
//#region src/database/migrations/061_restaurant_locations.ts
|
|
3023
3023
|
var _061_restaurant_locations_exports = /* @__PURE__ */ __exportAll({
|
|
3024
|
-
down: () => down$
|
|
3025
|
-
up: () => up$
|
|
3024
|
+
down: () => down$57,
|
|
3025
|
+
up: () => up$57
|
|
3026
3026
|
});
|
|
3027
|
-
async function up$
|
|
3027
|
+
async function up$57(db) {
|
|
3028
3028
|
await db.schema.createTable("restaurant_locations").addColumn("id", "text", (col) => col.primaryKey()).addColumn("slug", "text", (col) => col.notNull().unique()).addColumn("name", "text", (col) => col.notNull()).addColumn("status", "text", (col) => col.notNull().check(sql`status in ('active', 'archived')`).defaultTo("active")).addColumn("active_slot", "integer", (col) => col.unique().check(sql`active_slot between 1 and 5`)).addColumn("default_key", "text", (col) => col.unique().check(sql`default_key = 'default'`)).addColumn("timezone", "text", (col) => col.notNull()).addColumn("currency", "text", (col) => col.notNull()).addColumn("address_line1", "text").addColumn("address_line2", "text").addColumn("city", "text").addColumn("region", "text").addColumn("postal_code", "text").addColumn("country_code", "text").addColumn("latitude", "real").addColumn("longitude", "real").addColumn("phone", "text").addColumn("email", "text").addColumn("service_modes_json", "text", (col) => col.notNull().defaultTo("[]")).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addCheckConstraint("ck_restaurant_locations_active_slot", sql`(status = 'active' and active_slot is not null) or (status = 'archived' and active_slot is null)`).addCheckConstraint("ck_restaurant_locations_default_active", sql`default_key is null or status = 'active'`).execute();
|
|
3029
3029
|
await db.schema.createIndex("idx_restaurant_locations_status").on("restaurant_locations").column("status").execute();
|
|
3030
3030
|
await db.schema.createIndex("idx_restaurant_locations_created_at").on("restaurant_locations").column("created_at").execute();
|
|
@@ -3033,7 +3033,7 @@ async function up$56(db) {
|
|
|
3033
3033
|
await db.schema.createIndex("idx_restaurant_location_memberships_user_id").on("restaurant_location_memberships").column("user_id").execute();
|
|
3034
3034
|
await db.schema.createIndex("idx_restaurant_location_memberships_location_id").on("restaurant_location_memberships").column("location_id").execute();
|
|
3035
3035
|
}
|
|
3036
|
-
async function down$
|
|
3036
|
+
async function down$57(db) {
|
|
3037
3037
|
await db.schema.dropTable("restaurant_location_memberships").execute();
|
|
3038
3038
|
await db.schema.dropTable("restaurant_locations").execute();
|
|
3039
3039
|
}
|
|
@@ -3041,10 +3041,10 @@ async function down$56(db) {
|
|
|
3041
3041
|
//#endregion
|
|
3042
3042
|
//#region src/database/migrations/062_restaurant_menus.ts
|
|
3043
3043
|
var _062_restaurant_menus_exports = /* @__PURE__ */ __exportAll({
|
|
3044
|
-
down: () => down$
|
|
3045
|
-
up: () => up$
|
|
3044
|
+
down: () => down$56,
|
|
3045
|
+
up: () => up$56
|
|
3046
3046
|
});
|
|
3047
|
-
async function up$
|
|
3047
|
+
async function up$56(db) {
|
|
3048
3048
|
await db.schema.createTable("restaurant_menus").addColumn("id", "text", (col) => col.primaryKey()).addColumn("slug", "text", (col) => col.notNull().unique()).addColumn("name", "text", (col) => col.notNull()).addColumn("description", "text").addColumn("status", "text", (col) => col.notNull().check(sql`status in ('active', 'archived')`).defaultTo("active")).addColumn("is_published", "integer", (col) => col.notNull().check(sql`is_published in (0, 1)`).defaultTo(0)).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).execute();
|
|
3049
3049
|
await db.schema.createTable("restaurant_menu_location_assignments").addColumn("id", "text", (col) => col.primaryKey()).addColumn("menu_id", "text", (col) => col.notNull().references("restaurant_menus.id").onDelete("cascade")).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("cascade")).addColumn("is_active", "integer", (col) => col.notNull().check(sql`is_active in (0, 1)`).defaultTo(1)).addColumn("sort_order", "integer", (col) => col.notNull().check(sql`sort_order >= 0`).defaultTo(0)).addColumn("schedule_json", "text", (col) => col.notNull().defaultTo("[]")).addColumn("service_modes_json", "text", (col) => col.notNull().defaultTo("[]")).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_menu_location_assignment", ["menu_id", "location_id"]).execute();
|
|
3050
3050
|
await db.schema.createTable("restaurant_menu_sections").addColumn("id", "text", (col) => col.primaryKey()).addColumn("menu_id", "text", (col) => col.notNull().references("restaurant_menus.id").onDelete("cascade")).addColumn("slug", "text", (col) => col.notNull()).addColumn("name", "text", (col) => col.notNull()).addColumn("description", "text").addColumn("status", "text", (col) => col.notNull().check(sql`status in ('active', 'archived')`).defaultTo("active")).addColumn("is_visible", "integer", (col) => col.notNull().check(sql`is_visible in (0, 1)`).defaultTo(1)).addColumn("available_hours_json", "text", (col) => col.notNull().defaultTo("[]")).addColumn("sort_order", "integer", (col) => col.notNull().check(sql`sort_order >= 0`).defaultTo(0)).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_menu_section_slug", ["menu_id", "slug"]).execute();
|
|
@@ -3287,7 +3287,7 @@ async function createIndexes$9(db) {
|
|
|
3287
3287
|
]
|
|
3288
3288
|
]) await db.schema.createIndex(name).on(table).columns([...columns]).execute();
|
|
3289
3289
|
}
|
|
3290
|
-
async function down$
|
|
3290
|
+
async function down$56(db) {
|
|
3291
3291
|
await db.schema.dropTable("restaurant_menu_overrides").execute();
|
|
3292
3292
|
await db.schema.dropTable("restaurant_menu_item_translations").execute();
|
|
3293
3293
|
await db.schema.dropTable("restaurant_menu_item_modifier_groups").execute();
|
|
@@ -3303,11 +3303,11 @@ async function down$55(db) {
|
|
|
3303
3303
|
//#endregion
|
|
3304
3304
|
//#region src/database/migrations/063_restaurant_hours.ts
|
|
3305
3305
|
var _063_restaurant_hours_exports = /* @__PURE__ */ __exportAll({
|
|
3306
|
-
down: () => down$
|
|
3307
|
-
up: () => up$
|
|
3306
|
+
down: () => down$55,
|
|
3307
|
+
up: () => up$55
|
|
3308
3308
|
});
|
|
3309
3309
|
const SERVICE_SCOPE_CHECK = sql`service_scope in ('all', 'dine_in', 'pickup', 'delivery', 'reservations')`;
|
|
3310
|
-
async function up$
|
|
3310
|
+
async function up$55(db) {
|
|
3311
3311
|
await db.schema.createTable("restaurant_hours").addColumn("id", "text", (col) => col.primaryKey()).addColumn("weekday", "integer", (col) => col.notNull().check(sql`weekday between 0 and 6`)).addColumn("service_scope", "text", (col) => col.notNull().check(SERVICE_SCOPE_CHECK)).addColumn("windows_json", "text", (col) => col.notNull().defaultTo("[]")).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_hours_day_scope", ["weekday", "service_scope"]).execute();
|
|
3312
3312
|
await db.schema.createTable("restaurant_hours_overrides").addColumn("id", "text", (col) => col.primaryKey()).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("cascade")).addColumn("weekday", "integer", (col) => col.notNull().check(sql`weekday between 0 and 6`)).addColumn("service_scope", "text", (col) => col.notNull().check(SERVICE_SCOPE_CHECK)).addColumn("windows_json", "text", (col) => col.notNull().defaultTo("[]")).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_hours_override_day_scope", [
|
|
3313
3313
|
"location_id",
|
|
@@ -3436,7 +3436,7 @@ async function createIndexes$8(db) {
|
|
|
3436
3436
|
"ends_at"
|
|
3437
3437
|
]).execute();
|
|
3438
3438
|
}
|
|
3439
|
-
async function down$
|
|
3439
|
+
async function down$55(db) {
|
|
3440
3440
|
await db.schema.dropTable("restaurant_closures").execute();
|
|
3441
3441
|
await db.schema.dropTable("restaurant_special_hours").execute();
|
|
3442
3442
|
await db.schema.dropTable("restaurant_hours_overrides").execute();
|
|
@@ -3446,14 +3446,14 @@ async function down$54(db) {
|
|
|
3446
3446
|
//#endregion
|
|
3447
3447
|
//#region src/database/migrations/064_restaurant_reservations.ts
|
|
3448
3448
|
var _064_restaurant_reservations_exports = /* @__PURE__ */ __exportAll({
|
|
3449
|
-
down: () => down$
|
|
3450
|
-
up: () => up$
|
|
3449
|
+
down: () => down$54,
|
|
3450
|
+
up: () => up$54
|
|
3451
3451
|
});
|
|
3452
3452
|
const RESERVATION_STATUS_CHECK = sql`status in ('pending', 'confirmed', 'seated', 'completed', 'cancelled', 'no_show')`;
|
|
3453
3453
|
const RESERVATION_SOURCE_CHECK = sql`source in ('public', 'admin', 'mcp', 'import')`;
|
|
3454
3454
|
const HOLD_STATUS_CHECK = sql`status in ('active', 'committed', 'released', 'expired')`;
|
|
3455
3455
|
const ACTIVE_REMOVED_STATUS_CHECK = sql`status in ('active', 'removed')`;
|
|
3456
|
-
async function up$
|
|
3456
|
+
async function up$54(db) {
|
|
3457
3457
|
await createSettingsTables(db);
|
|
3458
3458
|
await createFloorTables(db);
|
|
3459
3459
|
await createReservationTables(db);
|
|
@@ -3812,7 +3812,7 @@ async function createIndexes$7(db) {
|
|
|
3812
3812
|
WHERE status = 'active'
|
|
3813
3813
|
`.execute(db);
|
|
3814
3814
|
}
|
|
3815
|
-
async function down$
|
|
3815
|
+
async function down$54(db) {
|
|
3816
3816
|
await db.schema.dropTable("restaurant_guest_access").execute();
|
|
3817
3817
|
await db.schema.dropTable("restaurant_reservation_table_assignments").execute();
|
|
3818
3818
|
await db.schema.dropTable("restaurant_reservation_holds").execute();
|
|
@@ -3828,8 +3828,8 @@ async function down$53(db) {
|
|
|
3828
3828
|
//#endregion
|
|
3829
3829
|
//#region src/database/migrations/065_restaurant_orders.ts
|
|
3830
3830
|
var _065_restaurant_orders_exports = /* @__PURE__ */ __exportAll({
|
|
3831
|
-
down: () => down$
|
|
3832
|
-
up: () => up$
|
|
3831
|
+
down: () => down$53,
|
|
3832
|
+
up: () => up$53
|
|
3833
3833
|
});
|
|
3834
3834
|
const ORDER_STATUS_CHECK = sql`status in ('pending_payment', 'confirmed', 'preparing', 'ready', 'out_for_delivery', 'completed', 'cancelled')`;
|
|
3835
3835
|
const ORDER_SOURCE_CHECK = sql`source in ('public', 'admin', 'mcp', 'import', 'qr')`;
|
|
@@ -3838,7 +3838,7 @@ const PAYMENT_STATUS_CHECK = sql`status in ('requires_action', 'processing', 'au
|
|
|
3838
3838
|
const REFUND_STATUS_CHECK = sql`status in ('pending', 'succeeded', 'failed', 'cancelled')`;
|
|
3839
3839
|
const CART_HOLD_STATUS_CHECK = sql`status in ('active', 'committed', 'released', 'expired')`;
|
|
3840
3840
|
const ACTOR_TYPE_CHECK = sql`actor_type in ('user', 'api_token', 'system')`;
|
|
3841
|
-
async function up$
|
|
3841
|
+
async function up$53(db) {
|
|
3842
3842
|
await createOrderTables$1(db);
|
|
3843
3843
|
await createPaymentTables$1(db);
|
|
3844
3844
|
await createIndexes$6(db);
|
|
@@ -4175,7 +4175,7 @@ async function createImmutableLedgerTriggers(db) {
|
|
|
4175
4175
|
`.execute(db);
|
|
4176
4176
|
}
|
|
4177
4177
|
}
|
|
4178
|
-
async function down$
|
|
4178
|
+
async function down$53(db) {
|
|
4179
4179
|
await db.schema.dropTable("restaurant_refunds").execute();
|
|
4180
4180
|
await db.schema.dropTable("restaurant_payments").execute();
|
|
4181
4181
|
await db.schema.dropTable("restaurant_cart_holds").execute();
|
|
@@ -4190,10 +4190,10 @@ async function down$52(db) {
|
|
|
4190
4190
|
//#endregion
|
|
4191
4191
|
//#region src/database/migrations/066_restaurant_stripe_configuration.ts
|
|
4192
4192
|
var _066_restaurant_stripe_configuration_exports = /* @__PURE__ */ __exportAll({
|
|
4193
|
-
down: () => down$
|
|
4194
|
-
up: () => up$
|
|
4193
|
+
down: () => down$52,
|
|
4194
|
+
up: () => up$52
|
|
4195
4195
|
});
|
|
4196
|
-
async function up$
|
|
4196
|
+
async function up$52(db) {
|
|
4197
4197
|
await db.schema.createTable("restaurant_stripe_settings").addColumn("id", "text", (col) => col.primaryKey()).addColumn("default_key", "text", (col) => col.notNull().unique().defaultTo("default")).addColumn("mode", "text", (col) => col.notNull().check(sql`mode in ('test', 'live')`).defaultTo("test")).addColumn("publishable_key", "text").addColumn("payments_enabled", "integer", (col) => col.notNull().check(sql`payments_enabled in (0, 1)`).defaultTo(0)).addColumn("enabled_fulfilment_types_json", "text", (col) => col.notNull().defaultTo("[\"pickup\"]")).addColumn("payment_flow", "text", (col) => col.notNull().check(sql`payment_flow in ('checkout', 'payment_element')`).defaultTo("checkout")).addColumn("automatic_tax_enabled", "integer", (col) => col.notNull().check(sql`automatic_tax_enabled in (0, 1)`).defaultTo(1)).addColumn("configuration_status", "text", (col) => col.notNull().check(sql`configuration_status in ('unconfigured', 'unverified', 'valid', 'invalid')`).defaultTo("unconfigured")).addColumn("stripe_account_id", "text").addColumn("charges_enabled", "integer", (col) => col.check(sql`charges_enabled is null or charges_enabled in (0, 1)`)).addColumn("details_submitted", "integer", (col) => col.check(sql`details_submitted is null or details_submitted in (0, 1)`)).addColumn("tax_status", "text", (col) => col.notNull().check(sql`tax_status in ('unknown', 'active', 'pending', 'unavailable')`).defaultTo("unknown")).addColumn("validation_error_code", "text").addColumn("last_validated_at", "text").addColumn("connect_status", "text", (col) => col.notNull().check(sql`connect_status in ('not_configured', 'restricted', 'ready')`).defaultTo("not_configured")).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addCheckConstraint("ck_restaurant_stripe_settings_default_key", sql`default_key = 'default'`).execute();
|
|
4198
4198
|
await db.schema.createTable("restaurant_stripe_location_settings").addColumn("id", "text", (col) => col.primaryKey()).addColumn("location_id", "text", (col) => col.notNull().unique().references("restaurant_locations.id").onDelete("cascade")).addColumn("payments_enabled", "integer", (col) => col.check(sql`payments_enabled is null or payments_enabled in (0, 1)`)).addColumn("enabled_fulfilment_types_json", "text").addColumn("payment_flow", "text", (col) => col.check(sql`payment_flow is null or payment_flow in ('checkout', 'payment_element')`)).addColumn("tax_mode", "text", (col) => col.check(sql`tax_mode is null or tax_mode in ('stripe_tax', 'manual_vat', 'none')`)).addColumn("manual_vat_reason", "text").addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addCheckConstraint("ck_restaurant_stripe_location_manual_vat_reason", sql`(tax_mode = 'manual_vat' and manual_vat_reason is not null and length(trim(manual_vat_reason)) > 0) or ((tax_mode is null or tax_mode <> 'manual_vat') and manual_vat_reason is null)`).execute();
|
|
4199
4199
|
await db.schema.createTable("restaurant_stripe_manual_tax_rates").addColumn("id", "text", (col) => col.primaryKey()).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("cascade")).addColumn("tax_code", "text", (col) => col.notNull().defaultTo("*")).addColumn("stripe_tax_rate_id", "text", (col) => col.notNull()).addColumn("display_name", "text", (col) => col.notNull()).addColumn("jurisdiction", "text", (col) => col.notNull()).addColumn("percentage", "text", (col) => col.notNull()).addColumn("inclusive", "integer", (col) => col.notNull().check(sql`inclusive in (0, 1)`).defaultTo(0)).addColumn("active", "integer", (col) => col.notNull().check(sql`active in (0, 1)`).defaultTo(1)).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_stripe_manual_tax_rates_mapping", ["location_id", "tax_code"]).execute();
|
|
@@ -4260,7 +4260,7 @@ async function up$51(db) {
|
|
|
4260
4260
|
"tax_code"
|
|
4261
4261
|
]).execute();
|
|
4262
4262
|
}
|
|
4263
|
-
async function down$
|
|
4263
|
+
async function down$52(db) {
|
|
4264
4264
|
await db.schema.dropTable("restaurant_stripe_manual_tax_rates").execute();
|
|
4265
4265
|
await db.schema.dropTable("restaurant_stripe_location_settings").execute();
|
|
4266
4266
|
await db.schema.dropTable("restaurant_stripe_settings").execute();
|
|
@@ -4269,10 +4269,10 @@ async function down$51(db) {
|
|
|
4269
4269
|
//#endregion
|
|
4270
4270
|
//#region src/database/migrations/067_restaurant_payment_requested_amount.ts
|
|
4271
4271
|
var _067_restaurant_payment_requested_amount_exports = /* @__PURE__ */ __exportAll({
|
|
4272
|
-
down: () => down$
|
|
4273
|
-
up: () => up$
|
|
4272
|
+
down: () => down$51,
|
|
4273
|
+
up: () => up$51
|
|
4274
4274
|
});
|
|
4275
|
-
async function up$
|
|
4275
|
+
async function up$51(db) {
|
|
4276
4276
|
await db.schema.alterTable("restaurant_payments").addColumn("amount_requested_minor", "integer", (column) => column.notNull().defaultTo(0).check(sql`amount_requested_minor >= 0`)).execute();
|
|
4277
4277
|
await sql`
|
|
4278
4278
|
UPDATE restaurant_payments
|
|
@@ -4288,19 +4288,19 @@ async function up$50(db) {
|
|
|
4288
4288
|
WHERE amount_requested_minor = 0
|
|
4289
4289
|
`.execute(db);
|
|
4290
4290
|
}
|
|
4291
|
-
async function down$
|
|
4291
|
+
async function down$51(db) {
|
|
4292
4292
|
await db.schema.alterTable("restaurant_payments").dropColumn("amount_requested_minor").execute();
|
|
4293
4293
|
}
|
|
4294
4294
|
|
|
4295
4295
|
//#endregion
|
|
4296
4296
|
//#region src/database/migrations/068_restaurant_stripe_events.ts
|
|
4297
4297
|
var _068_restaurant_stripe_events_exports = /* @__PURE__ */ __exportAll({
|
|
4298
|
-
down: () => down$
|
|
4299
|
-
up: () => up$
|
|
4298
|
+
down: () => down$50,
|
|
4299
|
+
up: () => up$50
|
|
4300
4300
|
});
|
|
4301
4301
|
const currentTimestamp = sql`(datetime('now'))`;
|
|
4302
4302
|
const retentionTimestamp = sql`(datetime('now', '+30 days'))`;
|
|
4303
|
-
async function up$
|
|
4303
|
+
async function up$50(db) {
|
|
4304
4304
|
await db.schema.createTable("restaurant_stripe_events").addColumn("id", "text", (col) => col.primaryKey()).addColumn("event_id", "text", (col) => col.notNull().unique()).addColumn("event_type", "text", (col) => col.notNull()).addColumn("livemode", "integer", (col) => col.notNull().check(sql`livemode in (0, 1)`)).addColumn("api_version", "text").addColumn("object_type", "text").addColumn("object_id", "text").addColumn("payload_sha256", "text", (col) => col.notNull().check(sql`length(payload_sha256) = 71 and payload_sha256 like 'sha256:%'`)).addColumn("status", "text", (col) => col.notNull().defaultTo("processing").check(sql`status in ('processing', 'processed', 'failed', 'ignored')`)).addColumn("attempt_count", "integer", (col) => col.notNull().defaultTo(1).check(sql`attempt_count >= 1`)).addColumn("error_code", "text", (col) => col.check(sql`length(error_code) <= 64`)).addColumn("location_id", "text", (col) => col.references("restaurant_locations.id").onDelete("set null")).addColumn("payment_id", "text", (col) => col.references("restaurant_payments.id").onDelete("set null")).addColumn("received_at", "text", (col) => col.notNull().defaultTo(currentTimestamp)).addColumn("last_attempt_at", "text", (col) => col.notNull().defaultTo(currentTimestamp)).addColumn("processed_at", "text").addColumn("retain_until", "text", (col) => col.notNull().defaultTo(retentionTimestamp)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp)).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp)).addCheckConstraint("ck_restaurant_stripe_events_object", sql`(object_type is null and object_id is null) or (object_type is not null and object_id is not null)`).addCheckConstraint("ck_restaurant_stripe_events_processed", sql`(status in ('processed', 'ignored') and processed_at is not null) or (status in ('processing', 'failed') and processed_at is null)`).addCheckConstraint("ck_restaurant_stripe_events_retention", sql`datetime(retain_until) >= datetime(received_at, '+30 days')`).execute();
|
|
4305
4305
|
for (const [name, column] of [
|
|
4306
4306
|
["idx_restaurant_stripe_events_status", "status"],
|
|
@@ -4317,22 +4317,22 @@ async function up$49(db) {
|
|
|
4317
4317
|
"id"
|
|
4318
4318
|
]).execute();
|
|
4319
4319
|
}
|
|
4320
|
-
async function down$
|
|
4320
|
+
async function down$50(db) {
|
|
4321
4321
|
await db.schema.dropTable("restaurant_stripe_events").execute();
|
|
4322
4322
|
}
|
|
4323
4323
|
|
|
4324
4324
|
//#endregion
|
|
4325
4325
|
//#region src/database/migrations/069_restaurant_tax_behavior.ts
|
|
4326
4326
|
var _069_restaurant_tax_behavior_exports = /* @__PURE__ */ __exportAll({
|
|
4327
|
-
down: () => down$
|
|
4328
|
-
up: () => up$
|
|
4327
|
+
down: () => down$49,
|
|
4328
|
+
up: () => up$49
|
|
4329
4329
|
});
|
|
4330
|
-
async function up$
|
|
4330
|
+
async function up$49(db) {
|
|
4331
4331
|
await db.schema.alterTable("restaurant_stripe_settings").addColumn("default_tax_behavior", "text", (column) => column.notNull().defaultTo("exclusive").check(sql`default_tax_behavior in ('exclusive', 'inclusive')`)).execute();
|
|
4332
4332
|
await db.schema.alterTable("restaurant_stripe_location_settings").addColumn("tax_behavior", "text", (column) => column.check(sql`tax_behavior is null or tax_behavior in ('exclusive', 'inclusive')`)).execute();
|
|
4333
4333
|
await db.schema.alterTable("restaurant_menu_items").addColumn("tax_behavior", "text", (column) => column.check(sql`tax_behavior is null or tax_behavior in ('exclusive', 'inclusive')`)).execute();
|
|
4334
4334
|
}
|
|
4335
|
-
async function down$
|
|
4335
|
+
async function down$49(db) {
|
|
4336
4336
|
await db.schema.alterTable("restaurant_menu_items").dropColumn("tax_behavior").execute();
|
|
4337
4337
|
await db.schema.alterTable("restaurant_stripe_location_settings").dropColumn("tax_behavior").execute();
|
|
4338
4338
|
await db.schema.alterTable("restaurant_stripe_settings").dropColumn("default_tax_behavior").execute();
|
|
@@ -4341,15 +4341,15 @@ async function down$48(db) {
|
|
|
4341
4341
|
//#endregion
|
|
4342
4342
|
//#region src/database/migrations/070_restaurant_inclusive_order_item_totals.ts
|
|
4343
4343
|
var _070_restaurant_inclusive_order_item_totals_exports = /* @__PURE__ */ __exportAll({
|
|
4344
|
-
down: () => down$
|
|
4345
|
-
up: () => up$
|
|
4344
|
+
down: () => down$48,
|
|
4345
|
+
up: () => up$48
|
|
4346
4346
|
});
|
|
4347
4347
|
const REBUILT_ORDER_ITEMS = "_restaurant_order_items_rebuild";
|
|
4348
4348
|
const REBUILT_ORDER_ITEM_MODIFIERS = "_restaurant_order_item_modifiers_rebuild";
|
|
4349
|
-
async function up$
|
|
4349
|
+
async function up$48(db) {
|
|
4350
4350
|
await rebuildOrderItemLedger(db, true);
|
|
4351
4351
|
}
|
|
4352
|
-
async function down$
|
|
4352
|
+
async function down$48(db) {
|
|
4353
4353
|
await rebuildOrderItemLedger(db, false);
|
|
4354
4354
|
}
|
|
4355
4355
|
async function rebuildOrderItemLedger(db, inclusiveAware) {
|
|
@@ -4472,11 +4472,11 @@ async function createImmutableTriggers(db) {
|
|
|
4472
4472
|
//#endregion
|
|
4473
4473
|
//#region src/database/migrations/071_restaurant_delivery_zones.ts
|
|
4474
4474
|
var _071_restaurant_delivery_zones_exports = /* @__PURE__ */ __exportAll({
|
|
4475
|
-
down: () => down$
|
|
4476
|
-
up: () => up$
|
|
4475
|
+
down: () => down$47,
|
|
4476
|
+
up: () => up$47
|
|
4477
4477
|
});
|
|
4478
4478
|
const DELIVERY_ZONE_STATUS_CHECK = sql`status in ('active', 'archived')`;
|
|
4479
|
-
async function up$
|
|
4479
|
+
async function up$47(db) {
|
|
4480
4480
|
await db.schema.createTable("restaurant_delivery_zones").addColumn("id", "text", (column) => column.primaryKey()).addColumn("location_id", "text", (column) => column.notNull().references("restaurant_locations.id").onDelete("cascade")).addColumn("name", "text", (column) => column.notNull()).addColumn("status", "text", (column) => column.notNull().check(DELIVERY_ZONE_STATUS_CHECK).defaultTo("active")).addColumn("priority", "integer", (column) => column.notNull().check(sql`priority >= 0`).defaultTo(0)).addColumn("radius_meters", "integer", (column) => column.check(sql`radius_meters is null or radius_meters > 0`)).addColumn("postal_codes_json", "text", (column) => column.notNull().defaultTo("[]")).addColumn("area_codes_json", "text", (column) => column.notNull().defaultTo("[]")).addColumn("fee_minor", "integer", (column) => column.notNull().check(sql`fee_minor >= 0`).defaultTo(0)).addColumn("minimum_order_minor", "integer", (column) => column.notNull().check(sql`minimum_order_minor >= 0`).defaultTo(0)).addColumn("estimated_minutes", "integer", (column) => column.notNull().check(sql`estimated_minutes between 1 and 1440`).defaultTo(45)).addColumn("version", "integer", (column) => column.notNull().check(sql`version >= 1`).defaultTo(1)).addColumn("created_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_delivery_zones_location_id", ["location_id", "id"]).execute();
|
|
4481
4481
|
await db.schema.createIndex("idx_restaurant_delivery_zones_location_status_priority").on("restaurant_delivery_zones").columns([
|
|
4482
4482
|
"location_id",
|
|
@@ -4485,35 +4485,35 @@ async function up$46(db) {
|
|
|
4485
4485
|
"id"
|
|
4486
4486
|
]).execute();
|
|
4487
4487
|
}
|
|
4488
|
-
async function down$
|
|
4488
|
+
async function down$47(db) {
|
|
4489
4489
|
await db.schema.dropTable("restaurant_delivery_zones").execute();
|
|
4490
4490
|
}
|
|
4491
4491
|
|
|
4492
4492
|
//#endregion
|
|
4493
4493
|
//#region src/database/migrations/072_restaurant_delivery_settings.ts
|
|
4494
4494
|
var _072_restaurant_delivery_settings_exports = /* @__PURE__ */ __exportAll({
|
|
4495
|
-
down: () => down$
|
|
4496
|
-
up: () => up$
|
|
4495
|
+
down: () => down$46,
|
|
4496
|
+
up: () => up$46
|
|
4497
4497
|
});
|
|
4498
4498
|
const SLOT_MINUTES_CHECK = sql`slot_minutes between 5 and 120 and slot_minutes % 5 = 0`;
|
|
4499
|
-
async function up$
|
|
4499
|
+
async function up$46(db) {
|
|
4500
4500
|
await db.schema.createTable("restaurant_delivery_settings").addColumn("id", "text", (column) => column.primaryKey()).addColumn("location_id", "text", (column) => column.notNull().unique().references("restaurant_locations.id").onDelete("cascade")).addColumn("slot_minutes", "integer", (column) => column.notNull().check(SLOT_MINUTES_CHECK).defaultTo(30)).addColumn("lead_minutes", "integer", (column) => column.notNull().check(sql`lead_minutes between 0 and 10080`).defaultTo(60)).addColumn("booking_horizon_days", "integer", (column) => column.notNull().check(sql`booking_horizon_days between 0 and 365`).defaultTo(14)).addColumn("version", "integer", (column) => column.notNull().check(sql`version >= 1`).defaultTo(1)).addColumn("created_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).execute();
|
|
4501
4501
|
await db.schema.createIndex("idx_restaurant_delivery_settings_location_id").on("restaurant_delivery_settings").column("location_id").execute();
|
|
4502
4502
|
}
|
|
4503
|
-
async function down$
|
|
4503
|
+
async function down$46(db) {
|
|
4504
4504
|
await db.schema.dropTable("restaurant_delivery_settings").execute();
|
|
4505
4505
|
}
|
|
4506
4506
|
|
|
4507
4507
|
//#endregion
|
|
4508
4508
|
//#region src/database/migrations/073_restaurant_dine_in.ts
|
|
4509
4509
|
var _073_restaurant_dine_in_exports = /* @__PURE__ */ __exportAll({
|
|
4510
|
-
down: () => down$
|
|
4511
|
-
up: () => up$
|
|
4510
|
+
down: () => down$45,
|
|
4511
|
+
up: () => up$45
|
|
4512
4512
|
});
|
|
4513
4513
|
const SESSION_STATUS_CHECK = sql`status in ('open', 'closed', 'cancelled')`;
|
|
4514
4514
|
const ROUND_PAYMENT_MODE_CHECK = sql`payment_mode in ('prepaid', 'offline', 'tab')`;
|
|
4515
4515
|
const ROUND_STATUS_CHECK = sql`status in ('open', 'authorized', 'settled', 'voided')`;
|
|
4516
|
-
async function up$
|
|
4516
|
+
async function up$45(db) {
|
|
4517
4517
|
await db.schema.createTable("restaurant_dine_in_sessions").addColumn("id", "text", (col) => col.primaryKey()).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("table_id", "text", (col) => col.notNull().references("restaurant_tables.id").onDelete("restrict")).addColumn("session_key", "text", (col) => col.notNull().unique()).addColumn("token_id", "text", (col) => col.notNull().unique()).addColumn("token_hash", "text", (col) => col.notNull().unique()).addColumn("service_date", "text", (col) => col.notNull().check(sql`length(service_date) = 10`)).addColumn("status", "text", (col) => col.notNull().check(SESSION_STATUS_CHECK).defaultTo("open")).addColumn("expires_at", "text", (col) => col.notNull()).addColumn("opened_at", "text", (col) => col.notNull()).addColumn("closed_at", "text").addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_dine_in_sessions_location_id", ["location_id", "id"]).addCheckConstraint("ck_restaurant_dine_in_sessions_state", sql`(status = 'open' and closed_at is null) or (status in ('closed', 'cancelled') and closed_at is not null)`).execute();
|
|
4518
4518
|
await db.schema.createTable("restaurant_tab_rounds").addColumn("id", "text", (col) => col.primaryKey()).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("session_id", "text", (col) => col.notNull()).addColumn("order_id", "text", (col) => col.notNull().unique()).addColumn("payment_id", "text", (col) => col.unique()).addColumn("round_number", "integer", (col) => col.notNull().check(sql`round_number >= 1`)).addColumn("request_key", "text", (col) => col.notNull().unique()).addColumn("payment_mode", "text", (col) => col.notNull().check(ROUND_PAYMENT_MODE_CHECK)).addColumn("status", "text", (col) => col.notNull().check(ROUND_STATUS_CHECK).defaultTo("open")).addColumn("authorization_ceiling_minor", "integer", (col) => col.notNull().check(sql`authorization_ceiling_minor >= 0`).defaultTo(0)).addColumn("amount_requested_minor", "integer", (col) => col.notNull().check(sql`amount_requested_minor > 0`)).addColumn("amount_authorized_minor", "integer", (col) => col.notNull().check(sql`amount_authorized_minor >= 0`).defaultTo(0)).addColumn("amount_captured_minor", "integer", (col) => col.notNull().check(sql`amount_captured_minor >= 0`).defaultTo(0)).addColumn("amount_refunded_minor", "integer", (col) => col.notNull().check(sql`amount_refunded_minor >= 0`).defaultTo(0)).addColumn("opened_at", "text", (col) => col.notNull()).addColumn("settled_at", "text").addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addForeignKeyConstraint("fk_restaurant_tab_rounds_session_location", ["location_id", "session_id"], "restaurant_dine_in_sessions", ["location_id", "id"], (cb) => cb.onDelete("restrict")).addForeignKeyConstraint("fk_restaurant_tab_rounds_order_location", ["location_id", "order_id"], "restaurant_orders", ["location_id", "id"], (cb) => cb.onDelete("restrict")).addForeignKeyConstraint("fk_restaurant_tab_rounds_payment_location", ["location_id", "payment_id"], "restaurant_payments", ["location_id", "id"], (cb) => cb.onDelete("restrict")).addUniqueConstraint("uq_restaurant_tab_rounds_session_number", ["session_id", "round_number"]).addUniqueConstraint("uq_restaurant_tab_rounds_location_id", ["location_id", "id"]).addCheckConstraint("ck_restaurant_tab_rounds_amounts", sql`amount_refunded_minor <= amount_captured_minor and amount_captured_minor <= amount_authorized_minor`).addCheckConstraint("ck_restaurant_tab_rounds_authorization", sql`payment_mode <> 'tab' or authorization_ceiling_minor >= amount_requested_minor`).addCheckConstraint("ck_restaurant_tab_rounds_settled", sql`(status = 'settled' and settled_at is not null) or (status <> 'settled' and settled_at is null)`).execute();
|
|
4519
4519
|
await db.schema.createIndex("idx_restaurant_dine_in_sessions_location_id").on("restaurant_dine_in_sessions").column("location_id").execute();
|
|
@@ -4541,7 +4541,7 @@ async function up$44(db) {
|
|
|
4541
4541
|
WHERE status = 'open'
|
|
4542
4542
|
`.execute(db);
|
|
4543
4543
|
}
|
|
4544
|
-
async function down$
|
|
4544
|
+
async function down$45(db) {
|
|
4545
4545
|
await db.schema.dropTable("restaurant_tab_rounds").execute();
|
|
4546
4546
|
await db.schema.dropTable("restaurant_dine_in_sessions").execute();
|
|
4547
4547
|
}
|
|
@@ -4549,11 +4549,11 @@ async function down$44(db) {
|
|
|
4549
4549
|
//#endregion
|
|
4550
4550
|
//#region src/database/migrations/074_restaurant_outbox.ts
|
|
4551
4551
|
var _074_restaurant_outbox_exports = /* @__PURE__ */ __exportAll({
|
|
4552
|
-
down: () => down$
|
|
4553
|
-
up: () => up$
|
|
4552
|
+
down: () => down$44,
|
|
4553
|
+
up: () => up$44
|
|
4554
4554
|
});
|
|
4555
4555
|
const OUTBOX_STATUS_CHECK = sql`status in ('pending', 'processing', 'delivered', 'failed')`;
|
|
4556
|
-
async function up$
|
|
4556
|
+
async function up$44(db) {
|
|
4557
4557
|
await db.schema.createTable("restaurant_outbox_events").addColumn("id", "text", (col) => col.primaryKey()).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("aggregate_type", "text", (col) => col.notNull().check(sql`length(aggregate_type) between 1 and 64`)).addColumn("aggregate_id", "text", (col) => col.notNull().check(sql`length(aggregate_id) between 1 and 128`)).addColumn("event_type", "text", (col) => col.notNull().check(sql`length(event_type) between 1 and 128`)).addColumn("dedupe_key", "text", (col) => col.notNull().unique()).addColumn("payload_json", "text", (col) => col.notNull()).addColumn("status", "text", (col) => col.notNull().check(OUTBOX_STATUS_CHECK).defaultTo("pending")).addColumn("attempt_count", "integer", (col) => col.notNull().check(sql`attempt_count >= 0`).defaultTo(0)).addColumn("available_at", "text", (col) => col.notNull()).addColumn("locked_until", "text").addColumn("last_error_code", "text").addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_outbox_location_id", ["location_id", "id"]).execute();
|
|
4558
4558
|
for (const [name, column] of [
|
|
4559
4559
|
["idx_restaurant_outbox_location_id", "location_id"],
|
|
@@ -4569,19 +4569,19 @@ async function up$43(db) {
|
|
|
4569
4569
|
"id"
|
|
4570
4570
|
]).execute();
|
|
4571
4571
|
}
|
|
4572
|
-
async function down$
|
|
4572
|
+
async function down$44(db) {
|
|
4573
4573
|
await db.schema.dropTable("restaurant_outbox_events").execute();
|
|
4574
4574
|
}
|
|
4575
4575
|
|
|
4576
4576
|
//#endregion
|
|
4577
4577
|
//#region src/database/migrations/075_restaurant_kds_tickets.ts
|
|
4578
4578
|
var _075_restaurant_kds_tickets_exports = /* @__PURE__ */ __exportAll({
|
|
4579
|
-
down: () => down$
|
|
4580
|
-
up: () => up$
|
|
4579
|
+
down: () => down$43,
|
|
4580
|
+
up: () => up$43
|
|
4581
4581
|
});
|
|
4582
4582
|
const FULFILMENT_TYPE_CHECK = sql`fulfilment_type in ('dine_in', 'pickup', 'delivery')`;
|
|
4583
4583
|
const KDS_STATUS_CHECK = sql`status in ('queued', 'preparing', 'ready', 'completed', 'cancelled')`;
|
|
4584
|
-
async function up$
|
|
4584
|
+
async function up$43(db) {
|
|
4585
4585
|
await db.schema.createTable("restaurant_kds_tickets").addColumn("id", "text", (col) => col.primaryKey()).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("order_id", "text", (col) => col.notNull().unique().references("restaurant_orders.id").onDelete("restrict")).addColumn("order_number", "integer", (col) => col.notNull().check(sql`order_number > 0`)).addColumn("fulfilment_type", "text", (col) => col.notNull().check(FULFILMENT_TYPE_CHECK)).addColumn("items_json", "text", (col) => col.notNull()).addColumn("status", "text", (col) => col.notNull().check(KDS_STATUS_CHECK).defaultTo("queued")).addColumn("priority", "integer", (col) => col.notNull().check(sql`priority >= 0`).defaultTo(0)).addColumn("started_at", "text").addColumn("ready_at", "text").addColumn("completed_at", "text").addColumn("cancelled_at", "text").addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_kds_tickets_location_id", ["location_id", "id"]).addForeignKeyConstraint("fk_restaurant_kds_tickets_order_location", ["location_id", "order_id"], "restaurant_orders", ["location_id", "id"], (cb) => cb.onDelete("restrict")).execute();
|
|
4586
4586
|
for (const [name, column] of [
|
|
4587
4587
|
["idx_restaurant_kds_tickets_location_id", "location_id"],
|
|
@@ -4599,38 +4599,38 @@ async function up$42(db) {
|
|
|
4599
4599
|
"id"
|
|
4600
4600
|
]).execute();
|
|
4601
4601
|
}
|
|
4602
|
-
async function down$
|
|
4602
|
+
async function down$43(db) {
|
|
4603
4603
|
await db.schema.dropTable("restaurant_kds_tickets").execute();
|
|
4604
4604
|
}
|
|
4605
4605
|
|
|
4606
4606
|
//#endregion
|
|
4607
4607
|
//#region src/database/migrations/076_restaurant_notification_settings.ts
|
|
4608
4608
|
var _076_restaurant_notification_settings_exports = /* @__PURE__ */ __exportAll({
|
|
4609
|
-
down: () => down$
|
|
4610
|
-
up: () => up$
|
|
4609
|
+
down: () => down$42,
|
|
4610
|
+
up: () => up$42
|
|
4611
4611
|
});
|
|
4612
4612
|
const SCOPE_CHECK = sql`(
|
|
4613
4613
|
(location_id is null and scope_key = 'global') or
|
|
4614
4614
|
(location_id is not null and scope_key = ('location:' || location_id))
|
|
4615
4615
|
)`;
|
|
4616
|
-
async function up$
|
|
4616
|
+
async function up$42(db) {
|
|
4617
4617
|
await db.schema.createTable("restaurant_notification_settings").addColumn("id", "text", (col) => col.primaryKey()).addColumn("scope_key", "text", (col) => col.notNull().unique()).addColumn("location_id", "text", (col) => col.references("restaurant_locations.id").onDelete("cascade")).addColumn("webhook_url", "text", (col) => col.check(sql`webhook_url is null or length(webhook_url) between 1 and 2048`)).addColumn("webhook_enabled", "integer", (col) => col.notNull().check(sql`webhook_enabled in (0, 1)`).defaultTo(0)).addColumn("webhook_event_types_json", "text", (col) => col.notNull().defaultTo("[]")).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addCheckConstraint("ck_restaurant_notification_settings_scope", SCOPE_CHECK).execute();
|
|
4618
4618
|
await db.schema.createIndex("idx_restaurant_notification_settings_location_id").on("restaurant_notification_settings").column("location_id").execute();
|
|
4619
4619
|
await db.schema.createIndex("idx_restaurant_notification_settings_updated_at").on("restaurant_notification_settings").column("updated_at").execute();
|
|
4620
4620
|
}
|
|
4621
|
-
async function down$
|
|
4621
|
+
async function down$42(db) {
|
|
4622
4622
|
await db.schema.dropTable("restaurant_notification_settings").execute();
|
|
4623
4623
|
}
|
|
4624
4624
|
|
|
4625
4625
|
//#endregion
|
|
4626
4626
|
//#region src/database/migrations/077_restaurant_outbox_deliveries.ts
|
|
4627
4627
|
var _077_restaurant_outbox_deliveries_exports = /* @__PURE__ */ __exportAll({
|
|
4628
|
-
down: () => down$
|
|
4629
|
-
up: () => up$
|
|
4628
|
+
down: () => down$41,
|
|
4629
|
+
up: () => up$41
|
|
4630
4630
|
});
|
|
4631
4631
|
const CHANNEL_CHECK = sql`channel in ('email', 'webhook', 'receipt', 'external_kds')`;
|
|
4632
4632
|
const DELIVERY_STATUS_CHECK = sql`status in ('pending', 'processing', 'delivered', 'failed')`;
|
|
4633
|
-
async function up$
|
|
4633
|
+
async function up$41(db) {
|
|
4634
4634
|
await db.schema.createTable("restaurant_outbox_deliveries").addColumn("id", "text", (col) => col.primaryKey()).addColumn("event_id", "text", (col) => col.notNull().references("restaurant_outbox_events.id").onDelete("cascade")).addColumn("channel", "text", (col) => col.notNull().check(CHANNEL_CHECK)).addColumn("status", "text", (col) => col.notNull().check(DELIVERY_STATUS_CHECK).defaultTo("pending")).addColumn("attempt_count", "integer", (col) => col.notNull().check(sql`attempt_count >= 0`).defaultTo(0)).addColumn("available_at", "text", (col) => col.notNull()).addColumn("locked_until", "text").addColumn("last_error_code", "text").addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_outbox_delivery_event_channel", ["event_id", "channel"]).execute();
|
|
4635
4635
|
await db.schema.createIndex("idx_restaurant_outbox_deliveries_event_id").on("restaurant_outbox_deliveries").column("event_id").execute();
|
|
4636
4636
|
await db.schema.createIndex("idx_restaurant_outbox_deliveries_channel").on("restaurant_outbox_deliveries").column("channel").execute();
|
|
@@ -4672,17 +4672,17 @@ async function up$40(db) {
|
|
|
4672
4672
|
ON CONFLICT (event_id, channel) DO NOTHING
|
|
4673
4673
|
`.execute(db);
|
|
4674
4674
|
}
|
|
4675
|
-
async function down$
|
|
4675
|
+
async function down$41(db) {
|
|
4676
4676
|
await db.schema.dropTable("restaurant_outbox_deliveries").execute();
|
|
4677
4677
|
}
|
|
4678
4678
|
|
|
4679
4679
|
//#endregion
|
|
4680
4680
|
//#region src/database/migrations/078_restaurant_external_kds_settings.ts
|
|
4681
4681
|
var _078_restaurant_external_kds_settings_exports = /* @__PURE__ */ __exportAll({
|
|
4682
|
-
down: () => down$
|
|
4683
|
-
up: () => up$
|
|
4682
|
+
down: () => down$40,
|
|
4683
|
+
up: () => up$40
|
|
4684
4684
|
});
|
|
4685
|
-
async function up$
|
|
4685
|
+
async function up$40(db) {
|
|
4686
4686
|
await db.schema.alterTable("restaurant_notification_settings").addColumn("external_kds_url", "text", (col) => col.check(sql`external_kds_url is null or length(external_kds_url) between 1 and 2048`)).execute();
|
|
4687
4687
|
await db.schema.alterTable("restaurant_notification_settings").addColumn("external_kds_enabled", "integer", (col) => col.notNull().check(sql`external_kds_enabled in (0, 1)`).defaultTo(0)).execute();
|
|
4688
4688
|
await db.schema.alterTable("restaurant_notification_settings").addColumn("external_kds_event_types_json", "text", (col) => col.notNull().defaultTo("[]")).execute();
|
|
@@ -4699,7 +4699,7 @@ async function up$39(db) {
|
|
|
4699
4699
|
ON CONFLICT (event_id, channel) DO NOTHING
|
|
4700
4700
|
`.execute(db);
|
|
4701
4701
|
}
|
|
4702
|
-
async function down$
|
|
4702
|
+
async function down$40(db) {
|
|
4703
4703
|
await db.schema.alterTable("restaurant_notification_settings").dropColumn("external_kds_event_types_json").execute();
|
|
4704
4704
|
await db.schema.alterTable("restaurant_notification_settings").dropColumn("external_kds_enabled").execute();
|
|
4705
4705
|
await db.schema.alterTable("restaurant_notification_settings").dropColumn("external_kds_url").execute();
|
|
@@ -4708,26 +4708,26 @@ async function down$39(db) {
|
|
|
4708
4708
|
//#endregion
|
|
4709
4709
|
//#region src/database/migrations/079_restaurant_dine_in_settings.ts
|
|
4710
4710
|
var _079_restaurant_dine_in_settings_exports = /* @__PURE__ */ __exportAll({
|
|
4711
|
-
down: () => down$
|
|
4712
|
-
up: () => up$
|
|
4711
|
+
down: () => down$39,
|
|
4712
|
+
up: () => up$39
|
|
4713
4713
|
});
|
|
4714
4714
|
const PAYMENT_MODE_CHECK = sql`default_payment_mode in ('prepaid', 'offline', 'tab')`;
|
|
4715
|
-
async function up$
|
|
4715
|
+
async function up$39(db) {
|
|
4716
4716
|
await db.schema.createTable("restaurant_dine_in_settings").ifNotExists().addColumn("id", "text", (column) => column.primaryKey()).addColumn("location_id", "text", (column) => column.notNull().unique().references("restaurant_locations.id").onDelete("cascade")).addColumn("qr_enabled", "integer", (column) => column.notNull().check(sql`qr_enabled in (0, 1)`).defaultTo(1)).addColumn("offline_payment_enabled", "integer", (column) => column.notNull().check(sql`offline_payment_enabled in (0, 1)`).defaultTo(1)).addColumn("open_tab_enabled", "integer", (column) => column.notNull().check(sql`open_tab_enabled in (0, 1)`).defaultTo(1)).addColumn("default_payment_mode", "text", (column) => column.notNull().check(PAYMENT_MODE_CHECK).defaultTo("prepaid")).addColumn("tab_authorization_ceiling_minor", "integer", (column) => column.notNull().check(sql`tab_authorization_ceiling_minor >= 0`).defaultTo(0)).addColumn("session_ttl_seconds", "integer", (column) => column.notNull().check(sql`session_ttl_seconds between 300 and 86400`).defaultTo(43200)).addColumn("version", "integer", (column) => column.notNull().check(sql`version >= 1`).defaultTo(1)).addColumn("created_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addCheckConstraint("ck_restaurant_dine_in_settings_default_mode", sql`default_payment_mode <> 'tab' or open_tab_enabled = 1`).execute();
|
|
4717
4717
|
await db.schema.createIndex("idx_restaurant_dine_in_settings_location_id").ifNotExists().on("restaurant_dine_in_settings").column("location_id").execute();
|
|
4718
4718
|
await db.schema.createIndex("idx_restaurant_dine_in_settings_updated_at").ifNotExists().on("restaurant_dine_in_settings").column("updated_at").execute();
|
|
4719
4719
|
}
|
|
4720
|
-
async function down$
|
|
4720
|
+
async function down$39(db) {
|
|
4721
4721
|
await db.schema.dropTable("restaurant_dine_in_settings").ifExists().execute();
|
|
4722
4722
|
}
|
|
4723
4723
|
|
|
4724
4724
|
//#endregion
|
|
4725
4725
|
//#region src/database/migrations/080_restaurant_operating_settings.ts
|
|
4726
4726
|
var _080_restaurant_operating_settings_exports = /* @__PURE__ */ __exportAll({
|
|
4727
|
-
down: () => down$
|
|
4728
|
-
up: () => up$
|
|
4727
|
+
down: () => down$38,
|
|
4728
|
+
up: () => up$38
|
|
4729
4729
|
});
|
|
4730
|
-
async function up$
|
|
4730
|
+
async function up$38(db) {
|
|
4731
4731
|
await db.schema.createTable("restaurant_operating_settings").addColumn("id", "text", (column) => column.primaryKey()).addColumn("scope_key", "text", (column) => column.notNull().unique()).addColumn("location_id", "text", (column) => column.unique().references("restaurant_locations.id").onDelete("cascade")).addColumn("default_currency", "text").addColumn("default_timezone", "text").addColumn("default_service_modes_json", "text").addColumn("tips_enabled", "integer", (column) => column.check(sql`tips_enabled in (0, 1)`)).addColumn("suggested_tip_percentages_json", "text").addColumn("service_fee_basis_points", "integer", (column) => column.check(sql`service_fee_basis_points between 0 and 10000`)).addColumn("version", "integer", (column) => column.notNull().check(sql`version >= 1`).defaultTo(1)).addColumn("created_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addCheckConstraint("ck_restaurant_operating_settings_scope", sql`(
|
|
4732
4732
|
location_id is null and scope_key = '*' and
|
|
4733
4733
|
default_currency is not null and default_timezone is not null and
|
|
@@ -4740,22 +4740,22 @@ async function up$37(db) {
|
|
|
4740
4740
|
await db.schema.createIndex("idx_restaurant_operating_settings_location_id").on("restaurant_operating_settings").column("location_id").execute();
|
|
4741
4741
|
await db.schema.createIndex("idx_restaurant_operating_settings_updated_at").on("restaurant_operating_settings").column("updated_at").execute();
|
|
4742
4742
|
}
|
|
4743
|
-
async function down$
|
|
4743
|
+
async function down$38(db) {
|
|
4744
4744
|
await db.schema.dropTable("restaurant_operating_settings").execute();
|
|
4745
4745
|
}
|
|
4746
4746
|
|
|
4747
4747
|
//#endregion
|
|
4748
4748
|
//#region src/database/migrations/081_restaurant_email_notification_settings.ts
|
|
4749
4749
|
var _081_restaurant_email_notification_settings_exports = /* @__PURE__ */ __exportAll({
|
|
4750
|
-
down: () => down$
|
|
4751
|
-
up: () => up$
|
|
4750
|
+
down: () => down$37,
|
|
4751
|
+
up: () => up$37
|
|
4752
4752
|
});
|
|
4753
|
-
async function up$
|
|
4753
|
+
async function up$37(db) {
|
|
4754
4754
|
await db.schema.alterTable("restaurant_notification_settings").addColumn("email_enabled", "integer", (col) => col.notNull().check(sql`email_enabled in (0, 1)`).defaultTo(0)).execute();
|
|
4755
4755
|
await db.schema.alterTable("restaurant_notification_settings").addColumn("email_event_types_json", "text", (col) => col.notNull().defaultTo("[]")).execute();
|
|
4756
4756
|
await db.schema.alterTable("restaurant_notification_settings").addColumn("email_templates_json", "text", (col) => col.notNull().defaultTo("{}")).execute();
|
|
4757
4757
|
}
|
|
4758
|
-
async function down$
|
|
4758
|
+
async function down$37(db) {
|
|
4759
4759
|
await db.schema.alterTable("restaurant_notification_settings").dropColumn("email_templates_json").execute();
|
|
4760
4760
|
await db.schema.alterTable("restaurant_notification_settings").dropColumn("email_event_types_json").execute();
|
|
4761
4761
|
await db.schema.alterTable("restaurant_notification_settings").dropColumn("email_enabled").execute();
|
|
@@ -4764,17 +4764,17 @@ async function down$36(db) {
|
|
|
4764
4764
|
//#endregion
|
|
4765
4765
|
//#region src/database/migrations/082_restaurant_reservation_checkout_holds.ts
|
|
4766
4766
|
var _082_restaurant_reservation_checkout_holds_exports = /* @__PURE__ */ __exportAll({
|
|
4767
|
-
down: () => down$
|
|
4768
|
-
up: () => up$
|
|
4767
|
+
down: () => down$36,
|
|
4768
|
+
up: () => up$36
|
|
4769
4769
|
});
|
|
4770
|
-
async function up$
|
|
4770
|
+
async function up$36(db) {
|
|
4771
4771
|
await db.schema.alterTable("restaurant_reservation_holds").addColumn("zone_id", "text", (col) => col.references("restaurant_zones.id").onDelete("set null")).execute();
|
|
4772
4772
|
await db.schema.alterTable("restaurant_reservation_holds").addColumn("token_id", "text").execute();
|
|
4773
4773
|
await db.schema.alterTable("restaurant_reservation_holds").addColumn("token_hash", "text").execute();
|
|
4774
4774
|
await db.schema.createIndex("idx_restaurant_reservation_holds_zone_id").on("restaurant_reservation_holds").column("zone_id").execute();
|
|
4775
4775
|
await db.schema.createIndex("idx_restaurant_reservation_holds_token_hash").unique().on("restaurant_reservation_holds").column("token_hash").execute();
|
|
4776
4776
|
}
|
|
4777
|
-
async function down$
|
|
4777
|
+
async function down$36(db) {
|
|
4778
4778
|
await db.schema.dropIndex("idx_restaurant_reservation_holds_token_hash").execute();
|
|
4779
4779
|
await db.schema.dropIndex("idx_restaurant_reservation_holds_zone_id").execute();
|
|
4780
4780
|
await db.schema.alterTable("restaurant_reservation_holds").dropColumn("token_hash").execute();
|
|
@@ -4785,10 +4785,10 @@ async function down$35(db) {
|
|
|
4785
4785
|
//#endregion
|
|
4786
4786
|
//#region src/database/migrations/083_restaurant_reservation_availability_indexes.ts
|
|
4787
4787
|
var _083_restaurant_reservation_availability_indexes_exports = /* @__PURE__ */ __exportAll({
|
|
4788
|
-
down: () => down$
|
|
4789
|
-
up: () => up$
|
|
4788
|
+
down: () => down$35,
|
|
4789
|
+
up: () => up$35
|
|
4790
4790
|
});
|
|
4791
|
-
async function up$
|
|
4791
|
+
async function up$35(db) {
|
|
4792
4792
|
await db.schema.createIndex("idx_restaurant_reservations_location_availability").on("restaurant_reservations").columns([
|
|
4793
4793
|
"location_id",
|
|
4794
4794
|
"status",
|
|
@@ -4803,7 +4803,7 @@ async function up$34(db) {
|
|
|
4803
4803
|
"expires_at"
|
|
4804
4804
|
]).execute();
|
|
4805
4805
|
}
|
|
4806
|
-
async function down$
|
|
4806
|
+
async function down$35(db) {
|
|
4807
4807
|
await db.schema.dropIndex("idx_restaurant_reservation_holds_location_availability").execute();
|
|
4808
4808
|
await db.schema.dropIndex("idx_restaurant_reservations_location_availability").execute();
|
|
4809
4809
|
}
|
|
@@ -4811,10 +4811,10 @@ async function down$34(db) {
|
|
|
4811
4811
|
//#endregion
|
|
4812
4812
|
//#region src/database/migrations/084_restaurant_reservation_demand.ts
|
|
4813
4813
|
var _084_restaurant_reservation_demand_exports = /* @__PURE__ */ __exportAll({
|
|
4814
|
-
down: () => down$
|
|
4815
|
-
up: () => up$
|
|
4814
|
+
down: () => down$34,
|
|
4815
|
+
up: () => up$34
|
|
4816
4816
|
});
|
|
4817
|
-
async function up$
|
|
4817
|
+
async function up$34(db) {
|
|
4818
4818
|
await createDemandSettings(db);
|
|
4819
4819
|
await createReservationRequests(db);
|
|
4820
4820
|
await createRequestTableAssignments(db);
|
|
@@ -4823,7 +4823,7 @@ async function up$33(db) {
|
|
|
4823
4823
|
await createPriorityAlertDeliveries(db);
|
|
4824
4824
|
await createIndexes$4(db);
|
|
4825
4825
|
}
|
|
4826
|
-
async function down$
|
|
4826
|
+
async function down$34(db) {
|
|
4827
4827
|
await db.schema.dropTable("restaurant_priority_alert_deliveries").execute();
|
|
4828
4828
|
await db.schema.dropTable("restaurant_priority_alert_opportunities").execute();
|
|
4829
4829
|
await db.schema.dropTable("restaurant_priority_alerts").execute();
|
|
@@ -4912,10 +4912,10 @@ async function createIndexes$4(db) {
|
|
|
4912
4912
|
//#endregion
|
|
4913
4913
|
//#region src/database/migrations/085_restaurant_reservation_offers.ts
|
|
4914
4914
|
var _085_restaurant_reservation_offers_exports = /* @__PURE__ */ __exportAll({
|
|
4915
|
-
down: () => down$
|
|
4916
|
-
up: () => up$
|
|
4915
|
+
down: () => down$33,
|
|
4916
|
+
up: () => up$33
|
|
4917
4917
|
});
|
|
4918
|
-
async function up$
|
|
4918
|
+
async function up$33(db) {
|
|
4919
4919
|
await db.schema.createTable("restaurant_reservation_offers").addColumn("id", "text", (col) => col.primaryKey()).addColumn("source_reservation_id", "text", (col) => col.notNull().unique().references("restaurant_reservations.id").onDelete("restrict")).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("zone_id", "text", (col) => col.references("restaurant_zones.id").onDelete("set null")).addColumn("hold_id", "text", (col) => col.notNull().unique().references("restaurant_reservation_holds.id").onDelete("restrict")).addColumn("request_key", "text", (col) => col.notNull().unique()).addColumn("token_id", "text", (col) => col.notNull().unique()).addColumn("token_hash", "text", (col) => col.notNull().unique()).addColumn("expires_at", "text", (col) => col.notNull()).addColumn("service_date", "text", (col) => col.notNull().check(sql`length(service_date) = 10`)).addColumn("starts_at", "text", (col) => col.notNull()).addColumn("ends_at", "text", (col) => col.notNull()).addColumn("duration_minutes", "integer", (col) => col.notNull().check(sql`duration_minutes between 30 and 240`)).addColumn("party_size", "integer", (col) => col.notNull().check(sql`party_size between 1 and 1000`)).addColumn("message", "text").addColumn("payment_mode", "text", (col) => col.notNull().check(sql`payment_mode in ('none', 'charge')`).defaultTo("none")).addColumn("amount_minor", "integer", (col) => col.check(sql`amount_minor is null or amount_minor > 0`)).addColumn("currency", "text", (col) => col.check(sql`currency is null or length(currency) = 3`)).addColumn("status", "text", (col) => col.notNull().check(sql`status in ('pending', 'accepted', 'declined', 'expired')`).defaultTo("pending")).addColumn("accepted_reservation_id", "text", (col) => col.references("restaurant_reservations.id").onDelete("restrict")).addColumn("offered_by_actor_type", "text", (col) => col.notNull().check(sql`offered_by_actor_type in ('user', 'api_token', 'system')`)).addColumn("offered_by_actor_id", "text").addColumn("accepted_at", "text").addColumn("declined_at", "text").addColumn("expired_at", "text").addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addCheckConstraint("ck_restaurant_reservation_offers_time", sql`ends_at > starts_at`).addCheckConstraint("ck_restaurant_reservation_offers_payment", sql`(payment_mode = 'none' and amount_minor is null and currency is null)
|
|
4920
4920
|
or (payment_mode = 'charge' and amount_minor is not null and currency is not null)`).addCheckConstraint("ck_restaurant_reservation_offers_state", sql`(
|
|
4921
4921
|
(status = 'pending' and accepted_reservation_id is null and accepted_at is null and declined_at is null and expired_at is null)
|
|
@@ -4929,17 +4929,17 @@ async function up$32(db) {
|
|
|
4929
4929
|
await db.schema.createIndex("idx_restaurant_reservation_offers_status_expires").on("restaurant_reservation_offers").columns(["status", "expires_at"]).execute();
|
|
4930
4930
|
await db.schema.createIndex("idx_restaurant_reservation_offers_created_at").on("restaurant_reservation_offers").column("created_at").execute();
|
|
4931
4931
|
}
|
|
4932
|
-
async function down$
|
|
4932
|
+
async function down$33(db) {
|
|
4933
4933
|
await db.schema.dropTable("restaurant_reservation_offers").execute();
|
|
4934
4934
|
}
|
|
4935
4935
|
|
|
4936
4936
|
//#endregion
|
|
4937
4937
|
//#region src/database/migrations/086_restaurant_reservation_payment_policies.ts
|
|
4938
4938
|
var _086_restaurant_reservation_payment_policies_exports = /* @__PURE__ */ __exportAll({
|
|
4939
|
-
down: () => down$
|
|
4940
|
-
up: () => up$
|
|
4939
|
+
down: () => down$32,
|
|
4940
|
+
up: () => up$32
|
|
4941
4941
|
});
|
|
4942
|
-
async function up$
|
|
4942
|
+
async function up$32(db) {
|
|
4943
4943
|
await db.schema.createTable("restaurant_reservation_payment_policies").addColumn("id", "text", (col) => col.primaryKey()).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("request_key", "text", (col) => col.notNull().unique()).addColumn("name", "text", (col) => col.notNull()).addColumn("scope_type", "text", (col) => col.notNull().check(sql`scope_type in ('venue_default', 'party_size', 'service_window', 'experience')`)).addColumn("experience_key", "text").addColumn("service_date", "text", (col) => col.check(sql`service_date is null or length(service_date) = 10`)).addColumn("starts_at_local", "text", (col) => col.check(sql`starts_at_local is null or length(starts_at_local) = 5`)).addColumn("ends_at_local", "text", (col) => col.check(sql`ends_at_local is null or length(ends_at_local) = 5`)).addColumn("min_party_size", "integer", (col) => col.check(sql`min_party_size is null or min_party_size between 1 and 1000`)).addColumn("max_party_size", "integer", (col) => col.check(sql`max_party_size is null or max_party_size between 1 and 1000`)).addColumn("collection_mode", "text", (col) => col.notNull().check(sql`collection_mode in ('none', 'charge', 'authorize')`).defaultTo("none")).addColumn("amount_basis", "text", (col) => col.notNull().check(sql`amount_basis in ('none', 'fixed', 'per_guest', 'quote_percentage', 'quote_total')`).defaultTo("none")).addColumn("amount_value", "integer").addColumn("currency", "text", (col) => col.check(sql`currency is null or length(currency) = 3`)).addColumn("cancellation_window_minutes", "integer", (col) => col.notNull().check(sql`cancellation_window_minutes >= 0`).defaultTo(1440)).addColumn("cancellation_fee_basis", "text", (col) => col.notNull().check(sql`cancellation_fee_basis in ('none', 'fixed', 'percentage', 'full')`).defaultTo("none")).addColumn("cancellation_fee_value", "integer").addColumn("cancellation_fee_currency", "text", (col) => col.check(sql`cancellation_fee_currency is null or length(cancellation_fee_currency) = 3`)).addColumn("modification_requires_review", "integer", (col) => col.notNull().check(sql`modification_requires_review in (0, 1)`).defaultTo(1)).addColumn("status", "text", (col) => col.notNull().check(sql`status in ('active', 'inactive')`).defaultTo("active")).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addCheckConstraint("ck_restaurant_reservation_payment_policies_scope", sql`(
|
|
4944
4944
|
(scope_type = 'venue_default' and experience_key is null and service_date is null and starts_at_local is null and ends_at_local is null and min_party_size is null and max_party_size is null)
|
|
4945
4945
|
or (scope_type = 'experience' and experience_key is not null and service_date is null and starts_at_local is null and ends_at_local is null and min_party_size is null and max_party_size is null)
|
|
@@ -4976,17 +4976,17 @@ async function up$31(db) {
|
|
|
4976
4976
|
]).execute();
|
|
4977
4977
|
await db.schema.createIndex("idx_restaurant_reservation_payment_policies_created_at").on("restaurant_reservation_payment_policies").column("created_at").execute();
|
|
4978
4978
|
}
|
|
4979
|
-
async function down$
|
|
4979
|
+
async function down$32(db) {
|
|
4980
4980
|
await db.schema.dropTable("restaurant_reservation_payment_policies").execute();
|
|
4981
4981
|
}
|
|
4982
4982
|
|
|
4983
4983
|
//#endregion
|
|
4984
4984
|
//#region src/database/migrations/087_restaurant_reservation_commercial_catalog.ts
|
|
4985
4985
|
var _087_restaurant_reservation_commercial_catalog_exports = /* @__PURE__ */ __exportAll({
|
|
4986
|
-
down: () => down$
|
|
4987
|
-
up: () => up$
|
|
4986
|
+
down: () => down$31,
|
|
4987
|
+
up: () => up$31
|
|
4988
4988
|
});
|
|
4989
|
-
async function up$
|
|
4989
|
+
async function up$31(db) {
|
|
4990
4990
|
await db.schema.createTable("restaurant_reservation_experiences").addColumn("id", "text", (col) => col.primaryKey()).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("request_key", "text", (col) => col.notNull().unique()).addColumn("experience_key", "text", (col) => col.notNull()).addColumn("name", "text", (col) => col.notNull()).addColumn("description", "text").addColumn("booking_mode", "text", (col) => col.notNull().check(sql`booking_mode in ('direct', 'request')`)).addColumn("price_basis", "text", (col) => col.notNull().check(sql`price_basis in ('none', 'fixed', 'per_guest', 'minimum_spend')`)).addColumn("price_minor", "integer").addColumn("currency", "text", (col) => col.check(sql`currency is null or length(currency) = 3`)).addColumn("duration_minutes", "integer", (col) => col.check(sql`duration_minutes is null or duration_minutes between 30 and 480`)).addColumn("min_party_size", "integer", (col) => col.notNull().check(sql`min_party_size between 1 and 1000`)).addColumn("max_party_size", "integer", (col) => col.notNull().check(sql`max_party_size between 1 and 1000`)).addColumn("max_bookings_per_slot", "integer", (col) => col.check(sql`max_bookings_per_slot is null or max_bookings_per_slot > 0`)).addColumn("max_covers_per_slot", "integer", (col) => col.check(sql`max_covers_per_slot is null or max_covers_per_slot > 0`)).addColumn("sales_start_at", "text").addColumn("sales_end_at", "text").addColumn("image_media_id", "text", (col) => col.references("media.id").onDelete("set null")).addColumn("image_alt_text", "text").addColumn("terms_text", "text").addColumn("status", "text", (col) => col.notNull().check(sql`status in ('draft', 'active', 'archived')`).defaultTo("draft")).addColumn("sort_order", "integer", (col) => col.notNull().defaultTo(0)).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_reservation_experiences_location_key", ["location_id", "experience_key"]).addCheckConstraint("ck_restaurant_reservation_experiences_price", sql`(price_basis = 'none' and price_minor is null and currency is null)
|
|
4991
4991
|
or (price_basis in ('fixed', 'per_guest', 'minimum_spend') and price_minor is not null and price_minor > 0 and currency is not null)`).addCheckConstraint("ck_restaurant_reservation_experiences_party_size", sql`min_party_size <= max_party_size`).addCheckConstraint("ck_restaurant_reservation_experiences_sales_window", sql`sales_start_at is null or sales_end_at is null or sales_end_at > sales_start_at`).execute();
|
|
4992
4992
|
await db.schema.createTable("restaurant_reservation_addon_categories").addColumn("id", "text", (col) => col.primaryKey()).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("request_key", "text", (col) => col.notNull().unique()).addColumn("category_key", "text", (col) => col.notNull()).addColumn("name", "text", (col) => col.notNull()).addColumn("description", "text").addColumn("available_for_standard", "integer", (col) => col.notNull().check(sql`available_for_standard in (0, 1)`).defaultTo(0)).addColumn("min_quantity", "integer", (col) => col.notNull().check(sql`min_quantity >= 0`).defaultTo(0)).addColumn("max_quantity", "integer", (col) => col.check(sql`max_quantity is null or max_quantity >= 0`)).addColumn("status", "text", (col) => col.notNull().check(sql`status in ('active', 'inactive', 'archived')`).defaultTo("active")).addColumn("sort_order", "integer", (col) => col.notNull().defaultTo(0)).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_reservation_addon_categories_location_key", ["location_id", "category_key"]).addCheckConstraint("ck_restaurant_reservation_addon_categories_quantity", sql`max_quantity is null or min_quantity <= max_quantity`).execute();
|
|
@@ -5069,7 +5069,7 @@ async function up$30(db) {
|
|
|
5069
5069
|
]
|
|
5070
5070
|
]) await db.schema.createIndex(name).on(table).columns([...columns]).execute();
|
|
5071
5071
|
}
|
|
5072
|
-
async function down$
|
|
5072
|
+
async function down$31(db) {
|
|
5073
5073
|
await db.schema.dropTable("restaurant_reservation_experience_included_addons").execute();
|
|
5074
5074
|
await db.schema.dropTable("restaurant_reservation_experience_addon_categories").execute();
|
|
5075
5075
|
await db.schema.dropTable("restaurant_reservation_addons").execute();
|
|
@@ -5080,10 +5080,10 @@ async function down$30(db) {
|
|
|
5080
5080
|
//#endregion
|
|
5081
5081
|
//#region src/database/migrations/088_restaurant_reservation_hold_commercial_allocations.ts
|
|
5082
5082
|
var _088_restaurant_reservation_hold_commercial_allocations_exports = /* @__PURE__ */ __exportAll({
|
|
5083
|
-
down: () => down$
|
|
5084
|
-
up: () => up$
|
|
5083
|
+
down: () => down$30,
|
|
5084
|
+
up: () => up$30
|
|
5085
5085
|
});
|
|
5086
|
-
async function up$
|
|
5086
|
+
async function up$30(db) {
|
|
5087
5087
|
await db.schema.createTable("restaurant_reservation_hold_commercial_selections").addColumn("id", "text", (col) => col.primaryKey()).addColumn("hold_id", "text", (col) => col.notNull().unique().references("restaurant_reservation_holds.id").onDelete("cascade")).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("experience_id", "text", (col) => col.references("restaurant_reservation_experiences.id").onDelete("restrict")).addColumn("experience_version", "integer").addColumn("revision", "integer", (col) => col.notNull().defaultTo(0)).addColumn("acknowledged_revision", "integer").addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addCheckConstraint("ck_restaurant_reservation_hold_commercial_experience", sql`(experience_id is null and experience_version is null)
|
|
5088
5088
|
or (experience_id is not null and experience_version is not null and experience_version > 0)`).addCheckConstraint("ck_restaurant_reservation_hold_commercial_revision", sql`revision >= 0 and (acknowledged_revision is null or acknowledged_revision between 0 and revision)`).execute();
|
|
5089
5089
|
await db.schema.createTable("restaurant_reservation_hold_addons").addColumn("id", "text", (col) => col.primaryKey()).addColumn("selection_id", "text", (col) => col.notNull().references("restaurant_reservation_hold_commercial_selections.id").onDelete("cascade")).addColumn("hold_id", "text", (col) => col.notNull().references("restaurant_reservation_holds.id").onDelete("cascade")).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("category_id", "text", (col) => col.notNull().references("restaurant_reservation_addon_categories.id").onDelete("restrict")).addColumn("addon_id", "text", (col) => col.notNull().references("restaurant_reservation_addons.id").onDelete("restrict")).addColumn("addon_version", "integer", (col) => col.notNull().check(sql`addon_version > 0`)).addColumn("allocation_kind", "text", (col) => col.notNull().check(sql`allocation_kind in ('included', 'selected')`)).addColumn("requested_quantity", "integer", (col) => col.notNull().check(sql`requested_quantity >= 0`)).addColumn("allocated_quantity", "integer", (col) => col.notNull().check(sql`allocated_quantity >= 0`)).addColumn("service_date", "text", (col) => col.notNull().check(sql`length(service_date) = 10`)).addColumn("starts_at", "text", (col) => col.notNull()).addColumn("expires_at", "text", (col) => col.notNull()).addColumn("status", "text", (col) => col.notNull().check(sql`status in ('active', 'committed', 'released', 'expired')`).defaultTo("active")).addColumn("released_at", "text").addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_reservation_hold_addon_kind", [
|
|
@@ -5147,7 +5147,7 @@ async function up$29(db) {
|
|
|
5147
5147
|
]
|
|
5148
5148
|
]) await db.schema.createIndex(name).on(table).columns([...columns]).execute();
|
|
5149
5149
|
}
|
|
5150
|
-
async function down$
|
|
5150
|
+
async function down$30(db) {
|
|
5151
5151
|
await db.schema.dropTable("restaurant_reservation_hold_addon_operations").execute();
|
|
5152
5152
|
await db.schema.dropTable("restaurant_reservation_hold_addons").execute();
|
|
5153
5153
|
await db.schema.dropTable("restaurant_reservation_hold_commercial_selections").execute();
|
|
@@ -5156,10 +5156,10 @@ async function down$29(db) {
|
|
|
5156
5156
|
//#endregion
|
|
5157
5157
|
//#region src/database/migrations/089_restaurant_reservation_quotes.ts
|
|
5158
5158
|
var _089_restaurant_reservation_quotes_exports = /* @__PURE__ */ __exportAll({
|
|
5159
|
-
down: () => down$
|
|
5160
|
-
up: () => up$
|
|
5159
|
+
down: () => down$29,
|
|
5160
|
+
up: () => up$29
|
|
5161
5161
|
});
|
|
5162
|
-
async function up$
|
|
5162
|
+
async function up$29(db) {
|
|
5163
5163
|
await db.schema.createTable("restaurant_reservation_quotes").addColumn("id", "text", (col) => col.primaryKey()).addColumn("hold_id", "text", (col) => col.notNull().references("restaurant_reservation_holds.id").onDelete("restrict")).addColumn("selection_id", "text", (col) => col.notNull().references("restaurant_reservation_hold_commercial_selections.id").onDelete("restrict")).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("payment_policy_id", "text", (col) => col.notNull().references("restaurant_reservation_payment_policies.id").onDelete("restrict")).addColumn("payment_policy_version", "integer", (col) => col.notNull().check(sql`payment_policy_version > 0`)).addColumn("experience_id", "text", (col) => col.references("restaurant_reservation_experiences.id").onDelete("restrict")).addColumn("experience_version", "integer").addColumn("selection_revision", "integer", (col) => col.notNull().check(sql`selection_revision >= 0`)).addColumn("collection_mode", "text", (col) => col.notNull().check(sql`collection_mode in ('none', 'charge', 'authorize')`)).addColumn("currency", "text", (col) => col.notNull().check(sql`length(currency) = 3`)).addColumn("subtotal_minor", "integer", (col) => col.notNull().check(sql`subtotal_minor >= 0`)).addColumn("discount_minor", "integer", (col) => col.notNull().check(sql`discount_minor >= 0 and discount_minor <= subtotal_minor`)).addColumn("fee_minor", "integer", (col) => col.notNull().check(sql`fee_minor >= 0`)).addColumn("tax_minor", "integer", (col) => col.notNull().check(sql`tax_minor >= 0`)).addColumn("gratuity_minor", "integer", (col) => col.notNull().check(sql`gratuity_minor >= 0`)).addColumn("total_minor", "integer", (col) => col.notNull().check(sql`total_minor >= 0`)).addColumn("due_now_minor", "integer", (col) => col.notNull().check(sql`due_now_minor >= 0`)).addColumn("authorization_minor", "integer", (col) => col.notNull().check(sql`authorization_minor >= 0`)).addColumn("pricing_hash", "text", (col) => col.notNull().check(sql`length(pricing_hash) = 71 and pricing_hash like 'sha256:%'`)).addColumn("snapshot_json", "text", (col) => col.notNull()).addColumn("expires_at", "text", (col) => col.notNull()).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_reservation_quotes_selection_revision", ["selection_id", "selection_revision"]).addCheckConstraint("ck_restaurant_reservation_quotes_experience", sql`(experience_id is null and experience_version is null)
|
|
5164
5164
|
or (experience_id is not null and experience_version is not null and experience_version > 0)`).addCheckConstraint("ck_restaurant_reservation_quotes_total", sql`total_minor = subtotal_minor - discount_minor + fee_minor + tax_minor + gratuity_minor`).addCheckConstraint("ck_restaurant_reservation_quotes_collection", sql`(collection_mode = 'none' and due_now_minor = 0 and authorization_minor = 0)
|
|
5165
5165
|
or (collection_mode = 'charge' and authorization_minor = 0)
|
|
@@ -5199,7 +5199,7 @@ async function up$28(db) {
|
|
|
5199
5199
|
]
|
|
5200
5200
|
]) await db.schema.createIndex(name).on(table).column(column).execute();
|
|
5201
5201
|
}
|
|
5202
|
-
async function down$
|
|
5202
|
+
async function down$29(db) {
|
|
5203
5203
|
await db.schema.dropTable("restaurant_reservation_quote_lines").execute();
|
|
5204
5204
|
await db.schema.dropTable("restaurant_reservation_quotes").execute();
|
|
5205
5205
|
}
|
|
@@ -5207,10 +5207,10 @@ async function down$28(db) {
|
|
|
5207
5207
|
//#endregion
|
|
5208
5208
|
//#region src/database/migrations/090_restaurant_reservation_quote_payments.ts
|
|
5209
5209
|
var _090_restaurant_reservation_quote_payments_exports = /* @__PURE__ */ __exportAll({
|
|
5210
|
-
down: () => down$
|
|
5211
|
-
up: () => up$
|
|
5210
|
+
down: () => down$28,
|
|
5211
|
+
up: () => up$28
|
|
5212
5212
|
});
|
|
5213
|
-
async function up$
|
|
5213
|
+
async function up$28(db) {
|
|
5214
5214
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
5215
5215
|
try {
|
|
5216
5216
|
await sql`
|
|
@@ -5285,7 +5285,7 @@ async function up$27(db) {
|
|
|
5285
5285
|
}
|
|
5286
5286
|
await assertForeignKeys$5(db);
|
|
5287
5287
|
}
|
|
5288
|
-
async function down$
|
|
5288
|
+
async function down$28(db) {
|
|
5289
5289
|
await db.schema.dropTable("restaurant_reservation_quote_checkouts").execute();
|
|
5290
5290
|
await sql`
|
|
5291
5291
|
DELETE FROM restaurant_refunds
|
|
@@ -5396,10 +5396,10 @@ async function assertForeignKeys$5(db) {
|
|
|
5396
5396
|
//#endregion
|
|
5397
5397
|
//#region src/database/migrations/091_restaurant_reservation_refunds.ts
|
|
5398
5398
|
var _091_restaurant_reservation_refunds_exports = /* @__PURE__ */ __exportAll({
|
|
5399
|
-
down: () => down$
|
|
5400
|
-
up: () => up$
|
|
5399
|
+
down: () => down$27,
|
|
5400
|
+
up: () => up$27
|
|
5401
5401
|
});
|
|
5402
|
-
async function up$
|
|
5402
|
+
async function up$27(db) {
|
|
5403
5403
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
5404
5404
|
try {
|
|
5405
5405
|
await sql`
|
|
@@ -5464,7 +5464,7 @@ async function up$26(db) {
|
|
|
5464
5464
|
}
|
|
5465
5465
|
await assertForeignKeys$4(db);
|
|
5466
5466
|
}
|
|
5467
|
-
async function down$
|
|
5467
|
+
async function down$27(db) {
|
|
5468
5468
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
5469
5469
|
try {
|
|
5470
5470
|
await sql`
|
|
@@ -5548,10 +5548,10 @@ async function assertForeignKeys$4(db) {
|
|
|
5548
5548
|
//#endregion
|
|
5549
5549
|
//#region src/database/migrations/092_restaurant_guest_profiles.ts
|
|
5550
5550
|
var _092_restaurant_guest_profiles_exports = /* @__PURE__ */ __exportAll({
|
|
5551
|
-
down: () => down$
|
|
5552
|
-
up: () => up$
|
|
5551
|
+
down: () => down$26,
|
|
5552
|
+
up: () => up$26
|
|
5553
5553
|
});
|
|
5554
|
-
async function up$
|
|
5554
|
+
async function up$26(db) {
|
|
5555
5555
|
await db.schema.createTable("restaurant_guest_profiles").addColumn("id", "text", (col) => col.primaryKey()).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("created_request_key", "text", (col) => col.notNull().unique()).addColumn("claimed_user_id", "text", (col) => col.references("users.id").onDelete("set null")).addColumn("display_name", "text", (col) => col.notNull().check(sql`length(display_name) between 1 and 160`)).addColumn("normalized_email", "text").addColumn("normalized_phone", "text").addColumn("preferred_language", "text", (col) => col.notNull().check(sql`length(preferred_language) between 2 and 35`).defaultTo("en")).addColumn("preferred_channel", "text", (col) => col.check(sql`preferred_channel in ('email', 'sms', 'whatsapp')`)).addColumn("priority_tier", "integer", (col) => col.notNull().check(sql`priority_tier between 0 and 100`).defaultTo(0)).addColumn("status", "text", (col) => col.notNull().check(sql`status in ('active', 'merged', 'anonymized')`).defaultTo("active")).addColumn("merged_into_id", "text", (col) => col.references("restaurant_guest_profiles.id").onDelete("restrict")).addColumn("last_activity_at", "text", (col) => col.notNull()).addColumn("anonymized_at", "text").addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addCheckConstraint("ck_restaurant_guest_profiles_identity", sql`(status = 'active' and (normalized_email is not null or normalized_phone is not null) and merged_into_id is null and anonymized_at is null) or (status = 'merged' and merged_into_id is not null and anonymized_at is null) or (status = 'anonymized' and normalized_email is null and normalized_phone is null and merged_into_id is null and anonymized_at is not null)`).addCheckConstraint("ck_restaurant_guest_profiles_distinct_merge", sql`merged_into_id is null or merged_into_id <> id`).execute();
|
|
5556
5556
|
await db.schema.createTable("restaurant_guest_profile_requests").addColumn("request_key", "text", (col) => col.primaryKey()).addColumn("profile_id", "text", (col) => col.notNull().references("restaurant_guest_profiles.id").onDelete("cascade")).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("input_fingerprint", "text", (col) => col.notNull().check(sql`length(input_fingerprint) = 64`)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).execute();
|
|
5557
5557
|
await db.schema.createTable("restaurant_guest_profile_reservations").addColumn("id", "text", (col) => col.primaryKey()).addColumn("profile_id", "text", (col) => col.notNull().references("restaurant_guest_profiles.id").onDelete("cascade")).addColumn("reservation_id", "text", (col) => col.notNull().unique().references("restaurant_reservations.id").onDelete("cascade")).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("match_source", "text", (col) => col.notNull().check(sql`match_source in ('contact', 'account', 'staff', 'import')`)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).execute();
|
|
@@ -5624,7 +5624,7 @@ async function up$25(db) {
|
|
|
5624
5624
|
await sql`CREATE UNIQUE INDEX idx_restaurant_guest_profiles_active_phone ON restaurant_guest_profiles(location_id, normalized_phone) WHERE status = 'active' AND normalized_phone IS NOT NULL`.execute(db);
|
|
5625
5625
|
await sql`CREATE UNIQUE INDEX idx_restaurant_guest_profiles_claimed_user_location ON restaurant_guest_profiles(location_id, claimed_user_id) WHERE status = 'active' AND claimed_user_id IS NOT NULL`.execute(db);
|
|
5626
5626
|
}
|
|
5627
|
-
async function down$
|
|
5627
|
+
async function down$26(db) {
|
|
5628
5628
|
await db.schema.dropTable("restaurant_guest_consents").execute();
|
|
5629
5629
|
await db.schema.dropTable("restaurant_guest_profile_reservations").execute();
|
|
5630
5630
|
await db.schema.dropTable("restaurant_guest_profile_requests").execute();
|
|
@@ -5634,24 +5634,24 @@ async function down$25(db) {
|
|
|
5634
5634
|
//#endregion
|
|
5635
5635
|
//#region src/database/migrations/093_restaurant_guest_profile_retention.ts
|
|
5636
5636
|
var _093_restaurant_guest_profile_retention_exports = /* @__PURE__ */ __exportAll({
|
|
5637
|
-
down: () => down$
|
|
5638
|
-
up: () => up$
|
|
5637
|
+
down: () => down$25,
|
|
5638
|
+
up: () => up$25
|
|
5639
5639
|
});
|
|
5640
|
-
async function up$
|
|
5640
|
+
async function up$25(db) {
|
|
5641
5641
|
await db.schema.createTable("restaurant_guest_profile_retention_settings").addColumn("id", "text", (col) => col.primaryKey()).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("cascade")).addColumn("inactivity_months", "integer", (col) => col.notNull().check(sql`inactivity_months between 1 and 120`).defaultTo(24)).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).execute();
|
|
5642
5642
|
await db.schema.createIndex("idx_restaurant_guest_profile_retention_location_id").unique().on("restaurant_guest_profile_retention_settings").column("location_id").execute();
|
|
5643
5643
|
}
|
|
5644
|
-
async function down$
|
|
5644
|
+
async function down$25(db) {
|
|
5645
5645
|
await db.schema.dropTable("restaurant_guest_profile_retention_settings").execute();
|
|
5646
5646
|
}
|
|
5647
5647
|
|
|
5648
5648
|
//#endregion
|
|
5649
5649
|
//#region src/database/migrations/094_restaurant_guest_profile_sharing.ts
|
|
5650
5650
|
var _094_restaurant_guest_profile_sharing_exports = /* @__PURE__ */ __exportAll({
|
|
5651
|
-
down: () => down$
|
|
5652
|
-
up: () => up$
|
|
5651
|
+
down: () => down$24,
|
|
5652
|
+
up: () => up$24
|
|
5653
5653
|
});
|
|
5654
|
-
async function up$
|
|
5654
|
+
async function up$24(db) {
|
|
5655
5655
|
await db.schema.createTable("restaurant_related_location_pairs").addColumn("id", "text", (col) => col.primaryKey()).addColumn("location_a_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("location_b_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("status", "text", (col) => col.notNull().check(sql`status in ('active', 'inactive')`)).addColumn("policy_version", "text", (col) => col.notNull().check(sql`length(policy_version) between 1 and 128`)).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_related_location_pairs_locations", ["location_a_id", "location_b_id"]).addCheckConstraint("ck_restaurant_related_location_pairs_canonical", sql`location_a_id < location_b_id`).execute();
|
|
5656
5656
|
await db.schema.createTable("restaurant_guest_profile_sharing_consents").addColumn("id", "text", (col) => col.primaryKey()).addColumn("pair_id", "text", (col) => col.notNull().references("restaurant_related_location_pairs.id").onDelete("restrict")).addColumn("profile_id", "text", (col) => col.notNull().references("restaurant_guest_profiles.id").onDelete("cascade")).addColumn("source_location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("target_location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("request_key", "text", (col) => col.notNull().unique()).addColumn("status", "text", (col) => col.notNull().check(sql`status in ('granted', 'withdrawn')`)).addColumn("source", "text", (col) => col.notNull().check(sql`source in ('checkout', 'account')`)).addColumn("policy_version", "text", (col) => col.notNull().check(sql`length(policy_version) between 1 and 128`)).addColumn("occurred_at", "text", (col) => col.notNull()).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addCheckConstraint("ck_restaurant_guest_profile_sharing_distinct_locations", sql`source_location_id <> target_location_id`).execute();
|
|
5657
5657
|
for (const [name, table, columns] of [
|
|
@@ -5697,7 +5697,7 @@ async function up$23(db) {
|
|
|
5697
5697
|
]
|
|
5698
5698
|
]) await db.schema.createIndex(name).on(table).columns([...columns]).execute();
|
|
5699
5699
|
}
|
|
5700
|
-
async function down$
|
|
5700
|
+
async function down$24(db) {
|
|
5701
5701
|
await db.schema.dropTable("restaurant_guest_profile_sharing_consents").execute();
|
|
5702
5702
|
await db.schema.dropTable("restaurant_related_location_pairs").execute();
|
|
5703
5703
|
}
|
|
@@ -5705,10 +5705,10 @@ async function down$23(db) {
|
|
|
5705
5705
|
//#endregion
|
|
5706
5706
|
//#region src/database/migrations/095_restaurant_priority_alert_notification_recovery.ts
|
|
5707
5707
|
var _095_restaurant_priority_alert_notification_recovery_exports = /* @__PURE__ */ __exportAll({
|
|
5708
|
-
down: () => down$
|
|
5709
|
-
up: () => up$
|
|
5708
|
+
down: () => down$23,
|
|
5709
|
+
up: () => up$23
|
|
5710
5710
|
});
|
|
5711
|
-
async function up$
|
|
5711
|
+
async function up$23(db) {
|
|
5712
5712
|
await db.schema.alterTable("restaurant_priority_alerts").addColumn("preferred_language", "text", (col) => col.notNull().defaultTo("en").check(sql`length(preferred_language) between 2 and 35`)).execute();
|
|
5713
5713
|
await db.schema.alterTable("restaurant_priority_alert_deliveries").addColumn("channel_attempt_count", "integer", (col) => col.notNull().defaultTo(0).check(sql`channel_attempt_count >= 0`)).execute();
|
|
5714
5714
|
await db.schema.alterTable("restaurant_priority_alert_deliveries").addColumn("fallback_count", "integer", (col) => col.notNull().defaultTo(0).check(sql`fallback_count >= 0`)).execute();
|
|
@@ -5718,7 +5718,7 @@ async function up$22(db) {
|
|
|
5718
5718
|
"id"
|
|
5719
5719
|
]).execute();
|
|
5720
5720
|
}
|
|
5721
|
-
async function down$
|
|
5721
|
+
async function down$23(db) {
|
|
5722
5722
|
await db.schema.dropIndex("idx_restaurant_priority_alert_deliveries_failure_queue").execute();
|
|
5723
5723
|
await db.schema.alterTable("restaurant_priority_alert_deliveries").dropColumn("fallback_count").execute();
|
|
5724
5724
|
await db.schema.alterTable("restaurant_priority_alert_deliveries").dropColumn("channel_attempt_count").execute();
|
|
@@ -5731,8 +5731,8 @@ var _096_restaurant_reservation_notification_preferences_exports = /* @__PURE__
|
|
|
5731
5731
|
addRestaurantReservationNotificationPreferenceColumns: () => addRestaurantReservationNotificationPreferenceColumns,
|
|
5732
5732
|
addRestaurantReservationQuoteCheckoutNotificationPreferenceColumns: () => addRestaurantReservationQuoteCheckoutNotificationPreferenceColumns,
|
|
5733
5733
|
addRestaurantReservationRequestNotificationPreferenceColumns: () => addRestaurantReservationRequestNotificationPreferenceColumns,
|
|
5734
|
-
down: () => down$
|
|
5735
|
-
up: () => up$
|
|
5734
|
+
down: () => down$22,
|
|
5735
|
+
up: () => up$22
|
|
5736
5736
|
});
|
|
5737
5737
|
async function addRestaurantReservationNotificationPreferenceColumns(db) {
|
|
5738
5738
|
await addNotificationPreferenceColumns(db, "restaurant_reservations");
|
|
@@ -5743,12 +5743,12 @@ async function addRestaurantReservationRequestNotificationPreferenceColumns(db)
|
|
|
5743
5743
|
async function addRestaurantReservationQuoteCheckoutNotificationPreferenceColumns(db) {
|
|
5744
5744
|
await addNotificationPreferenceColumns(db, "restaurant_reservation_quote_checkouts");
|
|
5745
5745
|
}
|
|
5746
|
-
async function up$
|
|
5746
|
+
async function up$22(db) {
|
|
5747
5747
|
await addRestaurantReservationNotificationPreferenceColumns(db);
|
|
5748
5748
|
await addRestaurantReservationRequestNotificationPreferenceColumns(db);
|
|
5749
5749
|
await addRestaurantReservationQuoteCheckoutNotificationPreferenceColumns(db);
|
|
5750
5750
|
}
|
|
5751
|
-
async function down$
|
|
5751
|
+
async function down$22(db) {
|
|
5752
5752
|
await dropNotificationPreferenceColumns(db, "restaurant_reservation_quote_checkouts");
|
|
5753
5753
|
await dropNotificationPreferenceColumns(db, "restaurant_reservation_requests");
|
|
5754
5754
|
await dropNotificationPreferenceColumns(db, "restaurant_reservations");
|
|
@@ -5767,12 +5767,12 @@ async function dropNotificationPreferenceColumns(db, table) {
|
|
|
5767
5767
|
//#endregion
|
|
5768
5768
|
//#region src/database/migrations/097_restaurant_guest_notification_recovery.ts
|
|
5769
5769
|
var _097_restaurant_guest_notification_recovery_exports = /* @__PURE__ */ __exportAll({
|
|
5770
|
-
down: () => down$
|
|
5771
|
-
up: () => up$
|
|
5770
|
+
down: () => down$21,
|
|
5771
|
+
up: () => up$21
|
|
5772
5772
|
});
|
|
5773
5773
|
const REBUILT_TABLE = "_restaurant_outbox_deliveries_097";
|
|
5774
5774
|
const DOWN_TABLE$3 = "_restaurant_outbox_deliveries_097_down";
|
|
5775
|
-
async function up$
|
|
5775
|
+
async function up$21(db) {
|
|
5776
5776
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
5777
5777
|
try {
|
|
5778
5778
|
await createRecoverableDeliveryTable(db, REBUILT_TABLE);
|
|
@@ -5796,7 +5796,7 @@ async function up$20(db) {
|
|
|
5796
5796
|
}
|
|
5797
5797
|
await assertForeignKeys$3(db);
|
|
5798
5798
|
}
|
|
5799
|
-
async function down$
|
|
5799
|
+
async function down$21(db) {
|
|
5800
5800
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
5801
5801
|
try {
|
|
5802
5802
|
await createLegacyDeliveryTable(db, DOWN_TABLE$3);
|
|
@@ -5848,12 +5848,12 @@ async function assertForeignKeys$3(db) {
|
|
|
5848
5848
|
//#endregion
|
|
5849
5849
|
//#region src/database/migrations/098_restaurant_private_event_requests.ts
|
|
5850
5850
|
var _098_restaurant_private_event_requests_exports = /* @__PURE__ */ __exportAll({
|
|
5851
|
-
down: () => down$
|
|
5852
|
-
up: () => up$
|
|
5851
|
+
down: () => down$20,
|
|
5852
|
+
up: () => up$20
|
|
5853
5853
|
});
|
|
5854
5854
|
const UP_TABLE$2 = "_restaurant_reservation_requests_098";
|
|
5855
5855
|
const DOWN_TABLE$2 = "_restaurant_reservation_requests_098_down";
|
|
5856
|
-
async function up$
|
|
5856
|
+
async function up$20(db) {
|
|
5857
5857
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
5858
5858
|
try {
|
|
5859
5859
|
await createExperienceRequestTable(db);
|
|
@@ -5890,7 +5890,7 @@ async function up$19(db) {
|
|
|
5890
5890
|
}
|
|
5891
5891
|
await assertForeignKeys$2(db);
|
|
5892
5892
|
}
|
|
5893
|
-
async function down$
|
|
5893
|
+
async function down$20(db) {
|
|
5894
5894
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
5895
5895
|
try {
|
|
5896
5896
|
await createLegacyRequestTable(db);
|
|
@@ -6077,10 +6077,10 @@ async function assertForeignKeys$2(db) {
|
|
|
6077
6077
|
//#endregion
|
|
6078
6078
|
//#region src/database/migrations/099_restaurant_reservation_promotions.ts
|
|
6079
6079
|
var _099_restaurant_reservation_promotions_exports = /* @__PURE__ */ __exportAll({
|
|
6080
|
-
down: () => down$
|
|
6081
|
-
up: () => up$
|
|
6080
|
+
down: () => down$19,
|
|
6081
|
+
up: () => up$19
|
|
6082
6082
|
});
|
|
6083
|
-
async function up$
|
|
6083
|
+
async function up$19(db) {
|
|
6084
6084
|
await db.schema.createTable("restaurant_reservation_promotions").addColumn("id", "text", (col) => col.primaryKey()).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("request_key", "text", (col) => col.notNull().unique()).addColumn("code_digest", "text", (col) => col.notNull().check(sql`length(code_digest) = 71 and code_digest like 'sha256:%'`)).addColumn("code_hint", "text", (col) => col.notNull().check(sql`length(code_hint) between 1 and 8`)).addColumn("name", "text", (col) => col.notNull().check(sql`length(name) between 1 and 160`)).addColumn("discount_type", "text", (col) => col.notNull().check(sql`discount_type in ('fixed', 'percentage')`)).addColumn("discount_value", "integer", (col) => col.notNull().check(sql`discount_value > 0`)).addColumn("max_discount_minor", "integer", (col) => col.check(sql`max_discount_minor is null or max_discount_minor > 0`)).addColumn("currency", "text", (col) => col.notNull().check(sql`length(currency) = 3`)).addColumn("applies_to", "text", (col) => col.notNull().check(sql`applies_to in ('all', 'experience', 'addons')`)).addColumn("service_starts_at", "text").addColumn("service_ends_at", "text").addColumn("max_redemptions", "integer", (col) => col.check(sql`max_redemptions is null or max_redemptions > 0`)).addColumn("reserved_count", "integer", (col) => col.notNull().defaultTo(0).check(sql`reserved_count >= 0`)).addColumn("redeemed_count", "integer", (col) => col.notNull().defaultTo(0).check(sql`redeemed_count >= 0`)).addColumn("status", "text", (col) => col.notNull().defaultTo("active").check(sql`status in ('active', 'archived')`)).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_reservation_promotions_location_code", ["location_id", "code_digest"]).addCheckConstraint("ck_restaurant_reservation_promotions_discount", sql`(discount_type = 'fixed' and max_discount_minor is null)
|
|
6085
6085
|
or (discount_type = 'percentage' and discount_value between 1 and 10000)`).addCheckConstraint("ck_restaurant_reservation_promotions_window", sql`service_starts_at is null or service_ends_at is null or service_ends_at > service_starts_at`).addCheckConstraint("ck_restaurant_reservation_promotions_counts", sql`max_redemptions is null or reserved_count + redeemed_count <= max_redemptions`).execute();
|
|
6086
6086
|
await db.schema.createTable("restaurant_reservation_promotion_allocations").addColumn("id", "text", (col) => col.primaryKey()).addColumn("promotion_id", "text", (col) => col.notNull().references("restaurant_reservation_promotions.id").onDelete("restrict")).addColumn("promotion_version", "integer", (col) => col.notNull().check(sql`promotion_version > 0`)).addColumn("selection_id", "text", (col) => col.notNull().references("restaurant_reservation_hold_commercial_selections.id").onDelete("restrict")).addColumn("hold_id", "text", (col) => col.notNull().references("restaurant_reservation_holds.id").onDelete("restrict")).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("reservation_id", "text", (col) => col.references("restaurant_reservations.id").onDelete("restrict")).addColumn("promotion_name", "text", (col) => col.notNull().check(sql`length(promotion_name) between 1 and 160`)).addColumn("code_hint", "text", (col) => col.notNull().check(sql`length(code_hint) between 1 and 8`)).addColumn("discount_type", "text", (col) => col.notNull().check(sql`discount_type in ('fixed', 'percentage')`)).addColumn("discount_value", "integer", (col) => col.notNull().check(sql`discount_value > 0`)).addColumn("max_discount_minor", "integer", (col) => col.check(sql`max_discount_minor is null or max_discount_minor > 0`)).addColumn("currency", "text", (col) => col.notNull().check(sql`length(currency) = 3`)).addColumn("applies_to", "text", (col) => col.notNull().check(sql`applies_to in ('all', 'experience', 'addons')`)).addColumn("expires_at", "text", (col) => col.notNull()).addColumn("status", "text", (col) => col.notNull().defaultTo("held").check(sql`status in ('held', 'attached', 'redeemed', 'released')`)).addColumn("attached_at", "text").addColumn("redeemed_at", "text").addColumn("released_at", "text").addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addCheckConstraint("ck_restaurant_reservation_promotion_allocations_discount", sql`(discount_type = 'fixed' and max_discount_minor is null)
|
|
@@ -6142,7 +6142,7 @@ async function up$18(db) {
|
|
|
6142
6142
|
WHERE status IN ('held', 'attached')
|
|
6143
6143
|
`.execute(db);
|
|
6144
6144
|
}
|
|
6145
|
-
async function down$
|
|
6145
|
+
async function down$19(db) {
|
|
6146
6146
|
await db.schema.dropTable("restaurant_reservation_promotion_operations").execute();
|
|
6147
6147
|
await db.schema.dropTable("restaurant_reservation_promotion_allocations").execute();
|
|
6148
6148
|
await db.schema.dropTable("restaurant_reservation_promotions").execute();
|
|
@@ -6151,10 +6151,10 @@ async function down$18(db) {
|
|
|
6151
6151
|
//#endregion
|
|
6152
6152
|
//#region src/database/migrations/100_restaurant_reservation_gift_cards.ts
|
|
6153
6153
|
var _100_restaurant_reservation_gift_cards_exports = /* @__PURE__ */ __exportAll({
|
|
6154
|
-
down: () => down$
|
|
6155
|
-
up: () => up$
|
|
6154
|
+
down: () => down$18,
|
|
6155
|
+
up: () => up$18
|
|
6156
6156
|
});
|
|
6157
|
-
async function up$
|
|
6157
|
+
async function up$18(db) {
|
|
6158
6158
|
await db.schema.createTable("restaurant_gift_cards").addColumn("id", "text", (col) => col.primaryKey()).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("request_key", "text", (col) => col.notNull().unique()).addColumn("request_hash", "text", (col) => col.notNull().check(sql`length(request_hash) = 64`)).addColumn("number_digest", "text", (col) => col.notNull().check(sql`length(number_digest) = 71 and number_digest like 'sha256:%'`)).addColumn("number_hint", "text", (col) => col.notNull().check(sql`length(number_hint) between 1 and 8`)).addColumn("pin_digest", "text", (col) => col.notNull().check(sql`length(pin_digest) = 71 and pin_digest like 'sha256:%'`)).addColumn("currency", "text", (col) => col.notNull().check(sql`length(currency) = 3`)).addColumn("available_minor", "integer", (col) => col.notNull().defaultTo(0).check(sql`available_minor >= 0`)).addColumn("held_minor", "integer", (col) => col.notNull().defaultTo(0).check(sql`held_minor >= 0`)).addColumn("status", "text", (col) => col.notNull().defaultTo("active").check(sql`status in ('active', 'inactive')`)).addColumn("version", "integer", (col) => col.notNull().defaultTo(1).check(sql`version > 0`)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_gift_cards_location_number", ["location_id", "number_digest"]).execute();
|
|
6159
6159
|
await db.schema.createTable("restaurant_reservation_gift_card_allocations").addColumn("id", "text", (col) => col.primaryKey()).addColumn("gift_card_id", "text", (col) => col.notNull().references("restaurant_gift_cards.id").onDelete("restrict")).addColumn("gift_card_version", "integer", (col) => col.notNull().check(sql`gift_card_version > 0`)).addColumn("selection_id", "text", (col) => col.notNull().references("restaurant_reservation_hold_commercial_selections.id").onDelete("restrict")).addColumn("hold_id", "text", (col) => col.notNull().references("restaurant_reservation_holds.id").onDelete("restrict")).addColumn("location_id", "text", (col) => col.notNull().references("restaurant_locations.id").onDelete("restrict")).addColumn("reservation_id", "text", (col) => col.references("restaurant_reservations.id").onDelete("restrict")).addColumn("card_hint", "text", (col) => col.notNull().check(sql`length(card_hint) between 1 and 8`)).addColumn("currency", "text", (col) => col.notNull().check(sql`length(currency) = 3`)).addColumn("amount_minor", "integer", (col) => col.notNull().check(sql`amount_minor > 0`)).addColumn("refunded_minor", "integer", (col) => col.notNull().defaultTo(0).check(sql`refunded_minor >= 0`)).addColumn("expires_at", "text", (col) => col.notNull()).addColumn("status", "text", (col) => col.notNull().defaultTo("held").check(sql`status in ('held', 'redeemed', 'released')`)).addColumn("redeemed_at", "text").addColumn("released_at", "text").addColumn("version", "integer", (col) => col.notNull().defaultTo(1).check(sql`version > 0`)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addCheckConstraint("ck_restaurant_reservation_gift_card_allocations_refund", sql`refunded_minor <= amount_minor`).addCheckConstraint("ck_restaurant_reservation_gift_card_allocations_state", sql`(status = 'held' and reservation_id is null and redeemed_at is null and released_at is null and refunded_minor = 0)
|
|
6160
6160
|
or (status = 'redeemed' and reservation_id is not null and redeemed_at is not null and released_at is null)
|
|
@@ -6233,7 +6233,7 @@ async function up$17(db) {
|
|
|
6233
6233
|
WHERE status = 'held'
|
|
6234
6234
|
`.execute(db);
|
|
6235
6235
|
}
|
|
6236
|
-
async function down$
|
|
6236
|
+
async function down$18(db) {
|
|
6237
6237
|
await db.schema.dropTable("restaurant_reservation_gift_card_operations").execute();
|
|
6238
6238
|
await db.schema.dropTable("restaurant_gift_card_ledger_entries").execute();
|
|
6239
6239
|
await db.schema.dropTable("restaurant_reservation_gift_card_allocations").execute();
|
|
@@ -6243,12 +6243,12 @@ async function down$17(db) {
|
|
|
6243
6243
|
//#endregion
|
|
6244
6244
|
//#region src/database/migrations/101_restaurant_reservation_request_payment_links.ts
|
|
6245
6245
|
var _101_restaurant_reservation_request_payment_links_exports = /* @__PURE__ */ __exportAll({
|
|
6246
|
-
down: () => down$
|
|
6247
|
-
up: () => up$
|
|
6246
|
+
down: () => down$17,
|
|
6247
|
+
up: () => up$17
|
|
6248
6248
|
});
|
|
6249
6249
|
const UP_TABLE$1 = "_restaurant_guest_access_101";
|
|
6250
6250
|
const DOWN_TABLE$1 = "_restaurant_guest_access_101_down";
|
|
6251
|
-
async function up$
|
|
6251
|
+
async function up$17(db) {
|
|
6252
6252
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
6253
6253
|
try {
|
|
6254
6254
|
await createGuestAccessTable$1(db, UP_TABLE$1, true);
|
|
@@ -6262,7 +6262,7 @@ async function up$16(db) {
|
|
|
6262
6262
|
}
|
|
6263
6263
|
await assertForeignKeys$1(db);
|
|
6264
6264
|
}
|
|
6265
|
-
async function down$
|
|
6265
|
+
async function down$17(db) {
|
|
6266
6266
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
6267
6267
|
try {
|
|
6268
6268
|
await db.schema.dropTable("restaurant_reservation_request_payment_link_deliveries").execute();
|
|
@@ -6325,12 +6325,12 @@ async function assertForeignKeys$1(db) {
|
|
|
6325
6325
|
//#endregion
|
|
6326
6326
|
//#region src/database/migrations/102_restaurant_reservation_offer_links.ts
|
|
6327
6327
|
var _102_restaurant_reservation_offer_links_exports = /* @__PURE__ */ __exportAll({
|
|
6328
|
-
down: () => down$
|
|
6329
|
-
up: () => up$
|
|
6328
|
+
down: () => down$16,
|
|
6329
|
+
up: () => up$16
|
|
6330
6330
|
});
|
|
6331
6331
|
const UP_TABLE = "_restaurant_guest_access_102";
|
|
6332
6332
|
const DOWN_TABLE = "_restaurant_guest_access_102_down";
|
|
6333
|
-
async function up$
|
|
6333
|
+
async function up$16(db) {
|
|
6334
6334
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
6335
6335
|
try {
|
|
6336
6336
|
await createGuestAccessTable(db, UP_TABLE, true);
|
|
@@ -6349,7 +6349,7 @@ async function up$15(db) {
|
|
|
6349
6349
|
}
|
|
6350
6350
|
await assertForeignKeys(db);
|
|
6351
6351
|
}
|
|
6352
|
-
async function down$
|
|
6352
|
+
async function down$16(db) {
|
|
6353
6353
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
6354
6354
|
try {
|
|
6355
6355
|
await db.schema.dropIndex("idx_restaurant_reservation_offers_location_created").execute();
|
|
@@ -6413,16 +6413,16 @@ async function assertForeignKeys(db) {
|
|
|
6413
6413
|
//#endregion
|
|
6414
6414
|
//#region src/database/migrations/103_restaurant_reservation_guest_details.ts
|
|
6415
6415
|
var _103_restaurant_reservation_guest_details_exports = /* @__PURE__ */ __exportAll({
|
|
6416
|
-
down: () => down$
|
|
6417
|
-
up: () => up$
|
|
6416
|
+
down: () => down$15,
|
|
6417
|
+
up: () => up$15
|
|
6418
6418
|
});
|
|
6419
|
-
async function up$
|
|
6419
|
+
async function up$15(db) {
|
|
6420
6420
|
await db.schema.createTable("restaurant_reservation_guest_settings").addColumn("id", "text", (column) => column.primaryKey()).addColumn("location_id", "text", (column) => column.notNull().unique().references("restaurant_locations.id").onDelete("cascade")).addColumn("login_mode", "text", (column) => column.notNull().check(sql`login_mode in ('guest', 'optional', 'required')`).defaultTo("optional")).addColumn("version", "integer", (column) => column.notNull().defaultTo(1)).addColumn("created_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).execute();
|
|
6421
6421
|
await db.schema.createTable("restaurant_reservation_guest_fields").addColumn("id", "text", (column) => column.primaryKey()).addColumn("location_id", "text", (column) => column.notNull().references("restaurant_locations.id").onDelete("cascade")).addColumn("request_key", "text", (column) => column.notNull().unique()).addColumn("field_key", "text", (column) => column.notNull()).addColumn("label", "text", (column) => column.notNull()).addColumn("description", "text").addColumn("input_type", "text", (column) => column.notNull().check(sql`input_type in ('text', 'textarea', 'select', 'checkbox')`)).addColumn("required", "integer", (column) => column.notNull().check(sql`required in (0, 1)`).defaultTo(0)).addColumn("options_json", "text").addColumn("placeholder", "text").addColumn("max_length", "integer", (column) => column.check(sql`max_length is null or max_length between 1 and 2000`)).addColumn("sort_order", "integer", (column) => column.notNull().defaultTo(0)).addColumn("status", "text", (column) => column.notNull().check(sql`status in ('active', 'inactive')`).defaultTo("active")).addColumn("version", "integer", (column) => column.notNull().defaultTo(1)).addColumn("created_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_reservation_guest_fields_location_key", ["location_id", "field_key"]).execute();
|
|
6422
6422
|
await db.schema.createTable("restaurant_reservation_guest_field_values").addColumn("id", "text", (column) => column.primaryKey()).addColumn("reservation_id", "text", (column) => column.notNull().references("restaurant_reservations.id").onDelete("cascade")).addColumn("field_id", "text", (column) => column.notNull().references("restaurant_reservation_guest_fields.id").onDelete("restrict")).addColumn("field_key", "text", (column) => column.notNull()).addColumn("field_label", "text", (column) => column.notNull()).addColumn("value_json", "text", (column) => column.notNull()).addColumn("created_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_reservation_guest_field_values_reservation_field", ["reservation_id", "field_id"]).execute();
|
|
6423
6423
|
await createIndexes$3(db);
|
|
6424
6424
|
}
|
|
6425
|
-
async function down$
|
|
6425
|
+
async function down$15(db) {
|
|
6426
6426
|
await db.schema.dropTable("restaurant_reservation_guest_field_values").execute();
|
|
6427
6427
|
await db.schema.dropTable("restaurant_reservation_guest_fields").execute();
|
|
6428
6428
|
await db.schema.dropTable("restaurant_reservation_guest_settings").execute();
|
|
@@ -6460,10 +6460,10 @@ async function createIndexes$3(db) {
|
|
|
6460
6460
|
//#endregion
|
|
6461
6461
|
//#region src/database/migrations/104_restaurant_reservation_quote_guest_details.ts
|
|
6462
6462
|
var _104_restaurant_reservation_quote_guest_details_exports = /* @__PURE__ */ __exportAll({
|
|
6463
|
-
down: () => down$
|
|
6464
|
-
up: () => up$
|
|
6463
|
+
down: () => down$14,
|
|
6464
|
+
up: () => up$14
|
|
6465
6465
|
});
|
|
6466
|
-
async function up$
|
|
6466
|
+
async function up$14(db) {
|
|
6467
6467
|
await db.schema.createTable("restaurant_reservation_quote_guest_contexts").addColumn("quote_id", "text", (column) => column.primaryKey().references("restaurant_reservation_quotes.id").onDelete("cascade")).addColumn("location_id", "text", (column) => column.notNull().references("restaurant_locations.id").onDelete("cascade")).addColumn("verified_user_id", "text", (column) => column.references("users.id").onDelete("set null")).addColumn("guest_profile_id", "text", (column) => column.notNull().references("restaurant_guest_profiles.id").onDelete("restrict")).addColumn("created_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).execute();
|
|
6468
6468
|
await db.schema.createTable("restaurant_reservation_quote_guest_field_values").addColumn("id", "text", (column) => column.primaryKey()).addColumn("quote_id", "text", (column) => column.notNull().references("restaurant_reservation_quotes.id").onDelete("cascade")).addColumn("field_id", "text", (column) => column.notNull().references("restaurant_reservation_guest_fields.id").onDelete("restrict")).addColumn("field_key", "text", (column) => column.notNull()).addColumn("field_label", "text", (column) => column.notNull()).addColumn("value_json", "text", (column) => column.notNull()).addColumn("created_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addUniqueConstraint("uq_restaurant_reservation_quote_guest_field_values_quote_field", ["quote_id", "field_id"]).execute();
|
|
6469
6469
|
for (const [name, table, columns] of [
|
|
@@ -6494,7 +6494,7 @@ async function up$13(db) {
|
|
|
6494
6494
|
]
|
|
6495
6495
|
]) await db.schema.createIndex(name).on(table).columns([...columns]).execute();
|
|
6496
6496
|
}
|
|
6497
|
-
async function down$
|
|
6497
|
+
async function down$14(db) {
|
|
6498
6498
|
await db.schema.dropTable("restaurant_reservation_quote_guest_field_values").execute();
|
|
6499
6499
|
await db.schema.dropTable("restaurant_reservation_quote_guest_contexts").execute();
|
|
6500
6500
|
}
|
|
@@ -6502,22 +6502,22 @@ async function down$13(db) {
|
|
|
6502
6502
|
//#endregion
|
|
6503
6503
|
//#region src/database/migrations/105_restaurant_reservation_language_settings.ts
|
|
6504
6504
|
var _105_restaurant_reservation_language_settings_exports = /* @__PURE__ */ __exportAll({
|
|
6505
|
-
down: () => down$
|
|
6506
|
-
up: () => up$
|
|
6505
|
+
down: () => down$13,
|
|
6506
|
+
up: () => up$13
|
|
6507
6507
|
});
|
|
6508
|
-
async function up$
|
|
6508
|
+
async function up$13(db) {
|
|
6509
6509
|
await db.schema.createTable("restaurant_reservation_language_settings").addColumn("id", "text", (column) => column.primaryKey()).addColumn("location_id", "text", (column) => column.notNull().unique().references("restaurant_locations.id").onDelete("cascade")).addColumn("default_language", "text", (column) => column.notNull().defaultTo("en")).addColumn("enabled_languages_json", "text", (column) => column.notNull().defaultTo("[\"en\"]")).addColumn("version", "integer", (column) => column.notNull().defaultTo(1)).addColumn("created_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).execute();
|
|
6510
6510
|
await db.schema.createIndex("idx_restaurant_reservation_language_settings_location_id").on("restaurant_reservation_language_settings").column("location_id").execute();
|
|
6511
6511
|
}
|
|
6512
|
-
async function down$
|
|
6512
|
+
async function down$13(db) {
|
|
6513
6513
|
await db.schema.dropTable("restaurant_reservation_language_settings").execute();
|
|
6514
6514
|
}
|
|
6515
6515
|
|
|
6516
6516
|
//#endregion
|
|
6517
6517
|
//#region src/database/migrations/106_restaurant_reservation_analytics.ts
|
|
6518
6518
|
var _106_restaurant_reservation_analytics_exports = /* @__PURE__ */ __exportAll({
|
|
6519
|
-
down: () => down$
|
|
6520
|
-
up: () => up$
|
|
6519
|
+
down: () => down$12,
|
|
6520
|
+
up: () => up$12
|
|
6521
6521
|
});
|
|
6522
6522
|
const EVENT_TYPE_CHECK = sql`event_type IN (
|
|
6523
6523
|
'flow_viewed',
|
|
@@ -6531,7 +6531,7 @@ const EVENT_TYPE_CHECK = sql`event_type IN (
|
|
|
6531
6531
|
'priority_alert_subscribed',
|
|
6532
6532
|
'management_viewed'
|
|
6533
6533
|
)`;
|
|
6534
|
-
async function up$
|
|
6534
|
+
async function up$12(db) {
|
|
6535
6535
|
await db.schema.createTable("restaurant_reservation_analytics_settings").addColumn("id", "text", (column) => column.primaryKey()).addColumn("location_id", "text", (column) => column.notNull().unique().references("restaurant_locations.id").onDelete("cascade")).addColumn("enabled", "integer", (column) => column.notNull().defaultTo(0)).addColumn("retention_days", "integer", (column) => column.notNull().defaultTo(90)).addColumn("version", "integer", (column) => column.notNull().defaultTo(1)).addColumn("created_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addCheckConstraint("ck_restaurant_reservation_analytics_settings_enabled", sql`enabled IN (0, 1)`).addCheckConstraint("ck_restaurant_reservation_analytics_settings_retention_days", sql`retention_days BETWEEN 1 AND 365`).execute();
|
|
6536
6536
|
await db.schema.createIndex("idx_restaurant_reservation_analytics_settings_location_id").on("restaurant_reservation_analytics_settings").column("location_id").execute();
|
|
6537
6537
|
await db.schema.createTable("restaurant_reservation_analytics_events").addColumn("id", "text", (column) => column.primaryKey()).addColumn("location_id", "text", (column) => column.notNull().references("restaurant_locations.id").onDelete("cascade")).addColumn("event_type", "text", (column) => column.notNull()).addColumn("occurred_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addCheckConstraint("ck_restaurant_reservation_analytics_events_type", EVENT_TYPE_CHECK).execute();
|
|
@@ -6539,7 +6539,7 @@ async function up$11(db) {
|
|
|
6539
6539
|
await db.schema.createIndex("idx_restaurant_reservation_analytics_events_location_occurred_at").on("restaurant_reservation_analytics_events").columns(["location_id", "occurred_at"]).execute();
|
|
6540
6540
|
await db.schema.createIndex("idx_restaurant_reservation_analytics_events_location_event_type").on("restaurant_reservation_analytics_events").columns(["location_id", "event_type"]).execute();
|
|
6541
6541
|
}
|
|
6542
|
-
async function down$
|
|
6542
|
+
async function down$12(db) {
|
|
6543
6543
|
await db.schema.dropTable("restaurant_reservation_analytics_events").execute();
|
|
6544
6544
|
await db.schema.dropTable("restaurant_reservation_analytics_settings").execute();
|
|
6545
6545
|
}
|
|
@@ -6547,10 +6547,10 @@ async function down$11(db) {
|
|
|
6547
6547
|
//#endregion
|
|
6548
6548
|
//#region src/database/migrations/107_payment_stripe_configuration.ts
|
|
6549
6549
|
var _107_payment_stripe_configuration_exports = /* @__PURE__ */ __exportAll({
|
|
6550
|
-
down: () => down$
|
|
6551
|
-
up: () => up$
|
|
6550
|
+
down: () => down$11,
|
|
6551
|
+
up: () => up$11
|
|
6552
6552
|
});
|
|
6553
|
-
async function up$
|
|
6553
|
+
async function up$11(db) {
|
|
6554
6554
|
await db.schema.createTable("payment_stripe_settings").addColumn("id", "text", (col) => col.primaryKey()).addColumn("default_key", "text", (col) => col.notNull().unique().defaultTo("default")).addColumn("mode", "text", (col) => col.notNull().check(sql`mode in ('test', 'live')`).defaultTo("test")).addColumn("publishable_key", "text").addColumn("configuration_status", "text", (col) => col.notNull().check(sql`configuration_status in ('unconfigured', 'unverified', 'valid', 'invalid')`).defaultTo("unconfigured")).addColumn("stripe_account_id", "text").addColumn("charges_enabled", "integer", (col) => col.check(sql`charges_enabled is null or charges_enabled in (0, 1)`)).addColumn("details_submitted", "integer", (col) => col.check(sql`details_submitted is null or details_submitted in (0, 1)`)).addColumn("tax_status", "text", (col) => col.notNull().check(sql`tax_status in ('unknown', 'active', 'pending', 'unavailable')`).defaultTo("unknown")).addColumn("validation_error_code", "text").addColumn("last_validated_at", "text").addColumn("connect_status", "text", (col) => col.notNull().check(sql`connect_status in ('not_configured', 'restricted', 'ready')`).defaultTo("not_configured")).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addCheckConstraint("ck_payment_stripe_settings_default_key", sql`default_key = 'default'`).execute();
|
|
6555
6555
|
await sql`
|
|
6556
6556
|
INSERT INTO payment_stripe_settings (
|
|
@@ -6568,22 +6568,22 @@ async function up$10(db) {
|
|
|
6568
6568
|
`.execute(db);
|
|
6569
6569
|
await db.schema.createIndex("idx_payment_stripe_settings_updated_at").on("payment_stripe_settings").column("updated_at").execute();
|
|
6570
6570
|
}
|
|
6571
|
-
async function down$
|
|
6571
|
+
async function down$11(db) {
|
|
6572
6572
|
await db.schema.dropTable("payment_stripe_settings").execute();
|
|
6573
6573
|
}
|
|
6574
6574
|
|
|
6575
6575
|
//#endregion
|
|
6576
6576
|
//#region src/database/migrations/108_venue_foundation.ts
|
|
6577
6577
|
var _108_venue_foundation_exports = /* @__PURE__ */ __exportAll({
|
|
6578
|
-
down: () => down$
|
|
6579
|
-
up: () => up$
|
|
6578
|
+
down: () => down$10,
|
|
6579
|
+
up: () => up$10
|
|
6580
6580
|
});
|
|
6581
6581
|
const RECORD_STATUS = sql`status in ('draft', 'active', 'archived')`;
|
|
6582
6582
|
const SPACE_STATUS = sql`status in ('draft', 'active', 'archived')`;
|
|
6583
6583
|
const BOOKING_MODE = sql`booking_mode in ('enquiry', 'request', 'instant')`;
|
|
6584
6584
|
const ORDER_STATUS = sql`status in ('enquired', 'requested', 'quoted', 'negotiating', 'accepted', 'payment_pending', 'confirmed', 'declined', 'withdrawn', 'expired', 'cancelled', 'completed')`;
|
|
6585
6585
|
const ORDER_HISTORY_TO_STATUS = sql`to_status in ('enquired', 'requested', 'quoted', 'negotiating', 'accepted', 'payment_pending', 'confirmed', 'declined', 'withdrawn', 'expired', 'cancelled', 'completed')`;
|
|
6586
|
-
async function up$
|
|
6586
|
+
async function up$10(db) {
|
|
6587
6587
|
await runStep("inventory tables", () => createInventoryTables(db));
|
|
6588
6588
|
await runStep("policy tables", () => createPolicyTables(db));
|
|
6589
6589
|
await runStep("order tables", () => createOrderTables(db));
|
|
@@ -6752,7 +6752,7 @@ async function createIndexes$2(db) {
|
|
|
6752
6752
|
throw new Error(`Index ${name} failed: ${message}`, { cause: error });
|
|
6753
6753
|
}
|
|
6754
6754
|
}
|
|
6755
|
-
async function down$
|
|
6755
|
+
async function down$10(db) {
|
|
6756
6756
|
await db.schema.dropTable("venue_availability_blocks").execute();
|
|
6757
6757
|
await db.schema.dropTable("venue_availability_rules").execute();
|
|
6758
6758
|
await db.schema.dropTable("venue_booking_holds").execute();
|
|
@@ -6770,10 +6770,10 @@ async function down$9(db) {
|
|
|
6770
6770
|
//#endregion
|
|
6771
6771
|
//#region src/database/migrations/109_venue_commercial_lifecycle.ts
|
|
6772
6772
|
var _109_venue_commercial_lifecycle_exports = /* @__PURE__ */ __exportAll({
|
|
6773
|
-
down: () => down$
|
|
6774
|
-
up: () => up$
|
|
6773
|
+
down: () => down$9,
|
|
6774
|
+
up: () => up$9
|
|
6775
6775
|
});
|
|
6776
|
-
async function up$
|
|
6776
|
+
async function up$9(db) {
|
|
6777
6777
|
await createCancellationTables(db);
|
|
6778
6778
|
await createQuoteTables(db);
|
|
6779
6779
|
await createPaymentTables(db);
|
|
@@ -6894,7 +6894,7 @@ async function createIndexes$1(db) {
|
|
|
6894
6894
|
]
|
|
6895
6895
|
]) await db.schema.createIndex(name).on(table).columns([...columns]).execute();
|
|
6896
6896
|
}
|
|
6897
|
-
async function down$
|
|
6897
|
+
async function down$9(db) {
|
|
6898
6898
|
await db.schema.dropTable("venue_payment_events").execute();
|
|
6899
6899
|
await db.schema.dropTable("venue_refunds").execute();
|
|
6900
6900
|
await db.schema.dropTable("venue_payments").execute();
|
|
@@ -6909,10 +6909,10 @@ async function down$8(db) {
|
|
|
6909
6909
|
//#endregion
|
|
6910
6910
|
//#region src/database/migrations/110_venue_communications_reviews.ts
|
|
6911
6911
|
var _110_venue_communications_reviews_exports = /* @__PURE__ */ __exportAll({
|
|
6912
|
-
down: () => down$
|
|
6913
|
-
up: () => up$
|
|
6912
|
+
down: () => down$8,
|
|
6913
|
+
up: () => up$8
|
|
6914
6914
|
});
|
|
6915
|
-
async function up$
|
|
6915
|
+
async function up$8(db) {
|
|
6916
6916
|
await createConversationTables(db);
|
|
6917
6917
|
await createNotificationTables(db);
|
|
6918
6918
|
await createReviewTables(db);
|
|
@@ -7031,7 +7031,7 @@ async function createIndexes(db) {
|
|
|
7031
7031
|
]
|
|
7032
7032
|
]) await db.schema.createIndex(name).on(table).columns([...columns]).execute();
|
|
7033
7033
|
}
|
|
7034
|
-
async function down$
|
|
7034
|
+
async function down$8(db) {
|
|
7035
7035
|
await db.schema.dropTable("venue_review_responses").execute();
|
|
7036
7036
|
await db.schema.dropTable("venue_reviews").execute();
|
|
7037
7037
|
await db.schema.dropTable("venue_review_invitations").execute();
|
|
@@ -7046,10 +7046,10 @@ async function down$7(db) {
|
|
|
7046
7046
|
//#endregion
|
|
7047
7047
|
//#region src/database/migrations/111_content_release_grants.ts
|
|
7048
7048
|
var _111_content_release_grants_exports = /* @__PURE__ */ __exportAll({
|
|
7049
|
-
down: () => down$
|
|
7050
|
-
up: () => up$
|
|
7049
|
+
down: () => down$7,
|
|
7050
|
+
up: () => up$7
|
|
7051
7051
|
});
|
|
7052
|
-
async function up$
|
|
7052
|
+
async function up$7(db) {
|
|
7053
7053
|
await db.schema.createTable("_dineway_content_release_grants").addColumn("id", "text", (column) => column.primaryKey()).addColumn("status", "text", (column) => column.notNull().defaultTo("active").check(sql`status in ('active', 'consumed', 'revoked', 'expired')`)).addColumn("collection", "text", (column) => column.notNull()).addColumn("entry_id", "text", (column) => column.notNull()).addColumn("scope", "text", (column) => column.notNull()).addColumn("live_revision_id", "text").addColumn("draft_revision_id", "text").addColumn("reviewed_rev", "text", (column) => column.notNull()).addColumn("editorial_review_request_id", "text", (column) => column.notNull().references("_dineway_review_requests.id").onDelete("restrict")).addColumn("release_hitl_request_id", "text", (column) => column.references("_dineway_hitl_requests.id").onDelete("restrict")).addColumn("operation", "text", (column) => column.notNull().check(sql`operation in ('publish', 'schedule')`)).addColumn("scheduled_at", "text").addColumn("published_at", "text").addColumn("site_timezone", "text", (column) => column.notNull()).addColumn("action_hash", "text", (column) => column.notNull()).addColumn("policy_contributions", "text", (column) => column.notNull().defaultTo("[]")).addColumn("authorization_method", "text", (column) => column.notNull().check(sql`authorization_method in ('human_action', 'approved_hitl')`)).addColumn("authorized_by_actor_type", "text", (column) => column.notNull().check(sql`authorized_by_actor_type in ('user', 'api_token', 'system')`)).addColumn("authorized_by_actor_id", "text", (column) => column.notNull()).addColumn("authorized_auth_metadata", "text").addColumn("expires_at", "text").addColumn("created_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (column) => column.notNull().defaultTo(currentTimestamp$1(db))).addColumn("consumed_at", "text").addColumn("revoked_at", "text").addColumn("revocation_reason", "text").addCheckConstraint("ck_dineway_content_release_grants_operation_time", sql`(operation = 'publish' and scheduled_at is null)
|
|
7054
7054
|
or (operation = 'schedule' and scheduled_at is not null and published_at is null)`).addCheckConstraint("ck_dineway_content_release_grants_authorization", sql`(authorization_method = 'human_action' and release_hitl_request_id is null)
|
|
7055
7055
|
or (authorization_method = 'approved_hitl' and release_hitl_request_id is not null)`).addCheckConstraint("ck_dineway_content_release_grants_terminal_state", sql`(status = 'active' and consumed_at is null and revoked_at is null)
|
|
@@ -7076,15 +7076,15 @@ async function up$6(db) {
|
|
|
7076
7076
|
WHERE status = 'active'
|
|
7077
7077
|
`.execute(db);
|
|
7078
7078
|
}
|
|
7079
|
-
async function down$
|
|
7079
|
+
async function down$7(db) {
|
|
7080
7080
|
await db.schema.dropTable("_dineway_content_release_grants").execute();
|
|
7081
7081
|
}
|
|
7082
7082
|
|
|
7083
7083
|
//#endregion
|
|
7084
7084
|
//#region src/database/migrations/114_assignment_overdue.ts
|
|
7085
7085
|
var _114_assignment_overdue_exports = /* @__PURE__ */ __exportAll({
|
|
7086
|
-
down: () => down$
|
|
7087
|
-
up: () => up$
|
|
7086
|
+
down: () => down$6,
|
|
7087
|
+
up: () => up$6
|
|
7088
7088
|
});
|
|
7089
7089
|
const ACTOR_TYPES = [
|
|
7090
7090
|
"user",
|
|
@@ -7108,7 +7108,7 @@ const PRIORITIES = [
|
|
|
7108
7108
|
"high",
|
|
7109
7109
|
"urgent"
|
|
7110
7110
|
];
|
|
7111
|
-
async function up$
|
|
7111
|
+
async function up$6(db) {
|
|
7112
7112
|
if (isSqlite(db)) {
|
|
7113
7113
|
await rebuildSqliteAssignments(db, true);
|
|
7114
7114
|
return;
|
|
@@ -7120,7 +7120,7 @@ async function up$5(db) {
|
|
|
7120
7120
|
"overdue"
|
|
7121
7121
|
]);
|
|
7122
7122
|
}
|
|
7123
|
-
async function down$
|
|
7123
|
+
async function down$6(db) {
|
|
7124
7124
|
if (isSqlite(db)) {
|
|
7125
7125
|
await rebuildSqliteAssignments(db, false);
|
|
7126
7126
|
return;
|
|
@@ -7245,28 +7245,28 @@ async function replacePostgresStatusConstraint(db, statuses) {
|
|
|
7245
7245
|
//#endregion
|
|
7246
7246
|
//#region src/database/migrations/115_integration_credentials.ts
|
|
7247
7247
|
var _115_integration_credentials_exports = /* @__PURE__ */ __exportAll({
|
|
7248
|
-
down: () => down$
|
|
7249
|
-
up: () => up$
|
|
7248
|
+
down: () => down$5,
|
|
7249
|
+
up: () => up$5
|
|
7250
7250
|
});
|
|
7251
|
-
async function up$
|
|
7251
|
+
async function up$5(db) {
|
|
7252
7252
|
await db.schema.createTable("_dineway_integration_credentials").addColumn("provider", "text", (col) => col.primaryKey()).addColumn("credential_type", "text", (col) => col.notNull()).addColumn("encryption_version", "integer", (col) => col.notNull()).addColumn("key_id", "text", (col) => col.notNull()).addColumn("nonce", "text", (col) => col.notNull()).addColumn("ciphertext", "text", (col) => col.notNull()).addColumn("fingerprint", "text", (col) => col.notNull()).addColumn("source", "text", (col) => col.notNull()).addColumn("created_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp$1(db))).execute();
|
|
7253
7253
|
await db.schema.createIndex("idx_dineway_integration_credentials_updated_at").on("_dineway_integration_credentials").column("updated_at").execute();
|
|
7254
7254
|
}
|
|
7255
|
-
async function down$
|
|
7255
|
+
async function down$5(db) {
|
|
7256
7256
|
await db.schema.dropTable("_dineway_integration_credentials").execute();
|
|
7257
7257
|
}
|
|
7258
7258
|
|
|
7259
7259
|
//#endregion
|
|
7260
7260
|
//#region src/database/migrations/116_repair_fts_sync_triggers.ts
|
|
7261
7261
|
var _116_repair_fts_sync_triggers_exports = /* @__PURE__ */ __exportAll({
|
|
7262
|
-
down: () => down$
|
|
7263
|
-
up: () => up$
|
|
7262
|
+
down: () => down$4,
|
|
7263
|
+
up: () => up$4
|
|
7264
7264
|
});
|
|
7265
7265
|
/**
|
|
7266
7266
|
* Rebuild enabled FTS5 indexes so existing sites receive the corrected
|
|
7267
7267
|
* external-content update and delete triggers before their next content write.
|
|
7268
7268
|
*/
|
|
7269
|
-
async function up$
|
|
7269
|
+
async function up$4(db) {
|
|
7270
7270
|
if (!isSqlite(db)) return;
|
|
7271
7271
|
const collections = await sql`
|
|
7272
7272
|
SELECT id, slug, search_config
|
|
@@ -7354,19 +7354,19 @@ function isSearchEnabled(searchConfig) {
|
|
|
7354
7354
|
return false;
|
|
7355
7355
|
}
|
|
7356
7356
|
}
|
|
7357
|
-
async function down$
|
|
7357
|
+
async function down$4(_db) {}
|
|
7358
7358
|
|
|
7359
7359
|
//#endregion
|
|
7360
7360
|
//#region src/database/migrations/117_content_taxonomy_covering_index.ts
|
|
7361
7361
|
var _117_content_taxonomy_covering_index_exports = /* @__PURE__ */ __exportAll({
|
|
7362
|
-
down: () => down$
|
|
7363
|
-
up: () => up$
|
|
7362
|
+
down: () => down$3,
|
|
7363
|
+
up: () => up$3
|
|
7364
7364
|
});
|
|
7365
7365
|
/**
|
|
7366
7366
|
* Replace the single-column taxonomy reverse index with a covering index for
|
|
7367
7367
|
* term-driven collection queries.
|
|
7368
7368
|
*/
|
|
7369
|
-
async function up$
|
|
7369
|
+
async function up$3(db) {
|
|
7370
7370
|
await db.schema.createIndex("idx_content_taxonomies_term_collection_entry").ifNotExists().on("content_taxonomies").columns([
|
|
7371
7371
|
"taxonomy_id",
|
|
7372
7372
|
"collection",
|
|
@@ -7374,7 +7374,7 @@ async function up$2(db) {
|
|
|
7374
7374
|
]).execute();
|
|
7375
7375
|
await db.schema.dropIndex("idx_content_taxonomies_term").ifExists().execute();
|
|
7376
7376
|
}
|
|
7377
|
-
async function down$
|
|
7377
|
+
async function down$3(db) {
|
|
7378
7378
|
await db.schema.createIndex("idx_content_taxonomies_term").ifNotExists().on("content_taxonomies").column("taxonomy_id").execute();
|
|
7379
7379
|
await db.schema.dropIndex("idx_content_taxonomies_term_collection_entry").ifExists().execute();
|
|
7380
7380
|
}
|
|
@@ -7382,14 +7382,14 @@ async function down$2(db) {
|
|
|
7382
7382
|
//#endregion
|
|
7383
7383
|
//#region src/database/migrations/118_collection_url_field.ts
|
|
7384
7384
|
var _118_collection_url_field_exports = /* @__PURE__ */ __exportAll({
|
|
7385
|
-
down: () => down$
|
|
7386
|
-
up: () => up$
|
|
7385
|
+
down: () => down$2,
|
|
7386
|
+
up: () => up$2
|
|
7387
7387
|
});
|
|
7388
|
-
async function up$
|
|
7388
|
+
async function up$2(db) {
|
|
7389
7389
|
await db.schema.alterTable("_dineway_collections").addColumn("url_field", "text").execute();
|
|
7390
7390
|
await updateIndexes(db, true);
|
|
7391
7391
|
}
|
|
7392
|
-
async function down$
|
|
7392
|
+
async function down$2(db) {
|
|
7393
7393
|
await updateIndexes(db, false);
|
|
7394
7394
|
await db.schema.alterTable("_dineway_collections").dropColumn("url_field").execute();
|
|
7395
7395
|
}
|
|
@@ -7406,14 +7406,54 @@ async function updateIndexes(db, create) {
|
|
|
7406
7406
|
//#endregion
|
|
7407
7407
|
//#region src/database/migrations/119_public_discovery_rules.ts
|
|
7408
7408
|
var _119_public_discovery_rules_exports = /* @__PURE__ */ __exportAll({
|
|
7409
|
+
down: () => down$1,
|
|
7410
|
+
up: () => up$1
|
|
7411
|
+
});
|
|
7412
|
+
async function up$1(db) {
|
|
7413
|
+
await db.schema.alterTable("_dineway_collections").addColumn("public_discovery", "text").execute();
|
|
7414
|
+
}
|
|
7415
|
+
async function down$1(db) {
|
|
7416
|
+
await db.schema.alterTable("_dineway_collections").dropColumn("public_discovery").execute();
|
|
7417
|
+
}
|
|
7418
|
+
|
|
7419
|
+
//#endregion
|
|
7420
|
+
//#region src/database/migrations/120_payment_subscriptions.ts
|
|
7421
|
+
var _120_payment_subscriptions_exports = /* @__PURE__ */ __exportAll({
|
|
7409
7422
|
down: () => down,
|
|
7410
7423
|
up: () => up
|
|
7411
7424
|
});
|
|
7425
|
+
const tables = [
|
|
7426
|
+
"payment_subscription_plans",
|
|
7427
|
+
"payment_subscription_prices",
|
|
7428
|
+
"payment_subscription_customers",
|
|
7429
|
+
"payment_member_subscriptions",
|
|
7430
|
+
"payment_subscription_periods",
|
|
7431
|
+
"payment_subscription_events",
|
|
7432
|
+
"payment_subscription_attempts",
|
|
7433
|
+
"payment_subscription_locks",
|
|
7434
|
+
"payment_subscription_portals"
|
|
7435
|
+
];
|
|
7412
7436
|
async function up(db) {
|
|
7413
|
-
|
|
7437
|
+
const base = (table) => db.schema.createTable(table).addColumn("scope", "text", (col) => col.notNull()).addColumn("id", "text", (col) => col.notNull()).addPrimaryKeyConstraint("pk_" + table, ["scope", "id"]);
|
|
7438
|
+
await base("payment_subscription_plans").addColumn("name", "text", (col) => col.notNull()).addColumn("enabled", "integer", (col) => col.notNull().defaultTo(0)).addColumn("entitlements", "text", (col) => col.notNull()).addColumn("version", "integer", (col) => col.notNull().defaultTo(1)).execute();
|
|
7439
|
+
await base("payment_subscription_prices").addColumn("plan_code", "text", (col) => col.notNull()).addColumn("product_id", "text", (col) => col.notNull()).addColumn("currency", "text", (col) => col.notNull()).addColumn("amount", "integer", (col) => col.notNull()).addColumn("interval", "text", (col) => col.notNull()).addColumn("enabled", "integer", (col) => col.notNull().defaultTo(1)).addForeignKeyConstraint("fk_payment_price_plan", ["scope", "plan_code"], "payment_subscription_plans", ["scope", "id"]).execute();
|
|
7440
|
+
await base("payment_subscription_customers").addColumn("customer_id", "text", (col) => col.notNull()).addUniqueConstraint("uq_payment_subscription_customer", ["scope", "customer_id"]).execute();
|
|
7441
|
+
await base("payment_member_subscriptions").addColumn("user_id", "text", (col) => col.notNull()).addColumn("customer_id", "text", (col) => col.notNull()).addColumn("plan_code", "text", (col) => col.notNull()).addColumn("price_id", "text", (col) => col.notNull()).addColumn("status", "text", (col) => col.notNull()).addColumn("period_end", "integer", (col) => col.notNull()).addColumn("cancel_at_period_end", "integer", (col) => col.notNull()).addColumn("verified_at", "integer", (col) => col.notNull()).addColumn("last_error", "text").addForeignKeyConstraint("fk_payment_subscription_user", ["scope", "user_id"], "payment_subscription_customers", ["scope", "id"]).addForeignKeyConstraint("fk_payment_subscription_price", ["scope", "price_id"], "payment_subscription_prices", ["scope", "id"]).execute();
|
|
7442
|
+
await base("payment_subscription_periods").addColumn("subscription_id", "text", (col) => col.notNull()).addColumn("invoice_id", "text", (col) => col.notNull()).addColumn("plan_code", "text", (col) => col.notNull()).addColumn("starts_at", "integer", (col) => col.notNull()).addColumn("ends_at", "integer", (col) => col.notNull()).addForeignKeyConstraint("fk_payment_period_subscription", ["scope", "subscription_id"], "payment_member_subscriptions", ["scope", "id"]).execute();
|
|
7443
|
+
await base("payment_subscription_events").addColumn("received_at", "integer", (col) => col.notNull()).execute();
|
|
7444
|
+
await base("payment_subscription_attempts").addColumn("fingerprint", "text", (col) => col.notNull()).addColumn("request_id", "text", (col) => col.notNull()).addColumn("session_id", "text").addColumn("created_at", "integer", (col) => col.notNull()).execute();
|
|
7445
|
+
await base("payment_subscription_locks").addColumn("token", "text", (col) => col.notNull()).addColumn("expires_at", "integer", (col) => col.notNull()).execute();
|
|
7446
|
+
for (const [table, column] of [
|
|
7447
|
+
["payment_subscription_prices", "plan_code"],
|
|
7448
|
+
["payment_member_subscriptions", "user_id"],
|
|
7449
|
+
["payment_member_subscriptions", "price_id"],
|
|
7450
|
+
["payment_subscription_periods", "subscription_id"],
|
|
7451
|
+
["payment_subscription_periods", "invoice_id"]
|
|
7452
|
+
]) await db.schema.createIndex("idx_" + table + "_" + column).on(table).columns(["scope", column]).execute();
|
|
7453
|
+
await base("payment_subscription_portals").addColumn("configuration_id", "text", (col) => col.notNull()).execute();
|
|
7414
7454
|
}
|
|
7415
7455
|
async function down(db) {
|
|
7416
|
-
await db.schema.
|
|
7456
|
+
for (const table of tables.toReversed()) await db.schema.dropTable(table).execute();
|
|
7417
7457
|
}
|
|
7418
7458
|
|
|
7419
7459
|
//#endregion
|
|
@@ -7534,7 +7574,8 @@ const MIGRATIONS = Object.freeze({
|
|
|
7534
7574
|
"116_repair_fts_sync_triggers": _116_repair_fts_sync_triggers_exports,
|
|
7535
7575
|
"117_content_taxonomy_covering_index": _117_content_taxonomy_covering_index_exports,
|
|
7536
7576
|
"118_collection_url_field": _118_collection_url_field_exports,
|
|
7537
|
-
"119_public_discovery_rules": _119_public_discovery_rules_exports
|
|
7577
|
+
"119_public_discovery_rules": _119_public_discovery_rules_exports,
|
|
7578
|
+
"120_payment_subscriptions": _120_payment_subscriptions_exports
|
|
7538
7579
|
});
|
|
7539
7580
|
const MIGRATION_NAMES = Object.freeze(Object.keys(MIGRATIONS).toSorted());
|
|
7540
7581
|
/** Total number of registered migrations. Exported for use in tests. */
|