dineway 0.2.33 → 0.2.35
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-CfryM8jO.mjs → activity-BbtYp_4V.mjs} +2 -2
- package/dist/{activity-events-BVo9rMUz.mjs → activity-events-CiFN61xq.mjs} +1 -1
- package/dist/{actor-DrJJsvy6.mjs → actor-DxUAJgQX.mjs} +20 -6
- package/dist/{adapters-DHt3f2lu.d.mts → adapters-Rol-inz6.d.mts} +5 -7
- package/dist/after-BVaUn7bK.mjs +24 -0
- package/dist/{allowed-origins-DGSyhRCz.mjs → allowed-origins-Cp7BI3L9.mjs} +1 -1
- package/dist/api/route-utils.d.mts +10 -10
- package/dist/api/route-utils.mjs +23 -19
- package/dist/api/schemas/index.d.mts +1 -1
- package/dist/api/schemas/index.mjs +5 -5
- package/dist/{api-CTf1SLmg.mjs → api-CwhrR7H5.mjs} +55 -1215
- package/dist/api-tokens-DA18zxza.mjs +3 -0
- package/dist/{api-tokens-CSomx-l3.mjs → api-tokens-OAgvq4xg.mjs} +1 -1
- package/dist/{apply-Bs2jXsms.mjs → apply-BTfAReIv.mjs} +109 -93
- package/dist/astro/index.d.mts +16 -12
- package/dist/astro/index.mjs +50 -9
- package/dist/astro/middleware/auth.d.mts +9 -9
- package/dist/astro/middleware/auth.mjs +29 -8
- package/dist/astro/middleware/redirect.mjs +8 -7
- package/dist/astro/middleware/request-context.mjs +17 -10
- package/dist/astro/middleware/seed.d.mts +1 -1
- package/dist/astro/middleware/seed.mjs +93 -71
- package/dist/astro/middleware/setup.mjs +1 -1
- package/dist/astro/middleware/workers.d.mts +6 -0
- package/dist/astro/middleware/workers.mjs +8 -0
- package/dist/astro/middleware.mjs +287 -159
- package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +7 -7
- package/dist/astro/routes/api/admin/allowed-domains/index.mjs +7 -7
- package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +4 -4
- package/dist/astro/routes/api/admin/api-tokens/index.mjs +7 -7
- package/dist/astro/routes/api/admin/briefing.mjs +25 -23
- package/dist/astro/routes/api/admin/byline-fields/_slug_/usage.mjs +5 -4
- package/dist/astro/routes/api/admin/byline-fields/_slug_.mjs +11 -10
- package/dist/astro/routes/api/admin/byline-fields/index.mjs +11 -10
- package/dist/astro/routes/api/admin/byline-fields/reorder.mjs +11 -10
- package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +22 -20
- package/dist/astro/routes/api/admin/bylines/_id_/translations.mjs +22 -20
- package/dist/astro/routes/api/admin/bylines/index.mjs +22 -20
- package/dist/astro/routes/api/admin/comments/_id_/status.mjs +18 -16
- package/dist/astro/routes/api/admin/comments/_id_.mjs +8 -7
- package/dist/astro/routes/api/admin/comments/bulk.mjs +14 -13
- package/dist/astro/routes/api/admin/comments/counts.mjs +8 -7
- package/dist/astro/routes/api/admin/comments/index.mjs +14 -13
- package/dist/astro/routes/api/admin/context/_id_/history.mjs +42 -31
- package/dist/astro/routes/api/admin/context/_id_/index.mjs +42 -31
- package/dist/astro/routes/api/admin/context/_id_/review.mjs +47 -36
- package/dist/astro/routes/api/admin/context/_id_/supersede.mjs +47 -36
- package/dist/astro/routes/api/admin/context/diff.mjs +46 -35
- package/dist/astro/routes/api/admin/context/index.mjs +47 -36
- package/dist/astro/routes/api/admin/context/stale.mjs +46 -35
- package/dist/astro/routes/api/admin/hitl-requests/_id_/index.mjs +42 -31
- package/dist/astro/routes/api/admin/hitl-requests/_id_/resolve.mjs +46 -35
- package/dist/astro/routes/api/admin/hitl-requests/index.mjs +46 -35
- package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +43 -32
- package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +3 -3
- package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +7 -7
- package/dist/astro/routes/api/admin/oauth-clients/index.mjs +7 -7
- package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +71 -66
- package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +71 -66
- package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +63 -58
- package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +70 -65
- package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +70 -65
- package/dist/astro/routes/api/admin/plugins/index.mjs +63 -58
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +2 -2
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +63 -58
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +70 -65
- package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +63 -58
- package/dist/astro/routes/api/admin/plugins/updates.mjs +63 -58
- package/dist/astro/routes/api/admin/review-requests/_id_/image.mjs +26 -23
- package/dist/astro/routes/api/admin/review-requests/_id_/index.mjs +39 -25
- package/dist/astro/routes/api/admin/review-requests/_id_/resolve.mjs +55 -43
- package/dist/astro/routes/api/admin/review-requests/_id_/revoke.mjs +10 -9
- package/dist/astro/routes/api/admin/review-requests/index.mjs +53 -41
- package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +63 -58
- package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +2 -2
- package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +63 -58
- package/dist/astro/routes/api/admin/users/_id_/disable.mjs +20 -12
- package/dist/astro/routes/api/admin/users/_id_/enable.mjs +1 -1
- package/dist/astro/routes/api/admin/users/_id_/index.mjs +40 -32
- package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +3 -3
- package/dist/astro/routes/api/admin/users/index.mjs +7 -7
- package/dist/astro/routes/api/auth/dev-bypass.mjs +6 -5
- package/dist/astro/routes/api/auth/invite/accept.mjs +1 -1
- package/dist/astro/routes/api/auth/invite/complete.mjs +12 -12
- package/dist/astro/routes/api/auth/invite/index.mjs +9 -9
- package/dist/astro/routes/api/auth/invite/register-options.mjs +11 -11
- package/dist/astro/routes/api/auth/logout.mjs +2 -2
- package/dist/astro/routes/api/auth/magic-link/send.mjs +12 -11
- package/dist/astro/routes/api/auth/magic-link/verify.mjs +2 -2
- package/dist/astro/routes/api/auth/me.mjs +11 -11
- package/dist/astro/routes/api/auth/mode.mjs +1 -1
- package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +5 -4
- package/dist/astro/routes/api/auth/oauth/_provider_.mjs +5 -4
- package/dist/astro/routes/api/auth/passkey/_id_.mjs +7 -7
- package/dist/astro/routes/api/auth/passkey/index.mjs +1 -1
- package/dist/astro/routes/api/auth/passkey/options.mjs +14 -13
- package/dist/astro/routes/api/auth/passkey/register/options.mjs +11 -11
- package/dist/astro/routes/api/auth/passkey/register/verify.mjs +12 -12
- package/dist/astro/routes/api/auth/passkey/verify.mjs +12 -12
- package/dist/astro/routes/api/auth/setup-token/index.mjs +32 -23
- package/dist/astro/routes/api/auth/setup-token/verify.mjs +32 -26
- package/dist/astro/routes/api/auth/signup/complete.mjs +12 -12
- package/dist/astro/routes/api/auth/signup/request.mjs +12 -11
- package/dist/astro/routes/api/auth/signup/verify.mjs +1 -1
- package/dist/astro/routes/api/comments/_collection_/_contentId_/index.d.mts +73 -2
- package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +91 -49
- package/dist/astro/routes/api/comments/_collection_/_contentId_/reactions.mjs +19 -16
- package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +2 -2
- package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +8 -7
- package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +8 -7
- package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +8 -7
- package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +24 -21
- package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +34 -22
- package/dist/astro/routes/api/content/_collection_/_id_/release-readiness.mjs +9 -9
- package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +8 -7
- package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +2 -2
- package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +34 -22
- package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +23 -19
- package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +2 -2
- package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +8 -7
- package/dist/astro/routes/api/content/_collection_/_id_.mjs +14 -13
- package/dist/astro/routes/api/content/_collection_/authors.mjs +2 -2
- package/dist/astro/routes/api/content/_collection_/index.mjs +14 -13
- package/dist/astro/routes/api/content/_collection_/trash.mjs +8 -8
- package/dist/astro/routes/api/dashboard.mjs +16 -11
- package/dist/astro/routes/api/dev/emails.mjs +2 -2
- package/dist/astro/routes/api/health.mjs +1 -1
- package/dist/astro/routes/api/import/probe.d.mts +3 -3
- package/dist/astro/routes/api/import/probe.mjs +25 -24
- package/dist/astro/routes/api/import/wordpress/analyze.mjs +12 -11
- package/dist/astro/routes/api/import/wordpress/execute.d.mts +9 -9
- package/dist/astro/routes/api/import/wordpress/execute.mjs +50 -42
- package/dist/astro/routes/api/import/wordpress/media.d.mts +9 -9
- package/dist/astro/routes/api/import/wordpress/media.mjs +14 -14
- package/dist/astro/routes/api/import/wordpress/prepare.mjs +51 -40
- package/dist/astro/routes/api/import/wordpress/rewrite-urls.d.mts +10 -10
- package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +49 -38
- package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
- package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +29 -27
- package/dist/astro/routes/api/import/wordpress-plugin/callback.mjs +1 -1
- package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +9 -9
- package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +55 -47
- package/dist/astro/routes/api/integration/artifact.mjs +11 -8
- package/dist/astro/routes/api/integration/dispatch.mjs +17 -14
- package/dist/astro/routes/api/integrations/_provider_.mjs +11 -8
- package/dist/astro/routes/api/integrations/index.mjs +10 -7
- package/dist/astro/routes/api/manifest.mjs +5 -5
- package/dist/astro/routes/api/mcp.mjs +97 -88
- package/dist/astro/routes/api/media/_id_/confirm.mjs +12 -12
- package/dist/astro/routes/api/media/_id_.mjs +9 -9
- package/dist/astro/routes/api/media/file/_...key_.mjs +1 -1
- package/dist/astro/routes/api/media/providers/_providerId_/_itemId_.mjs +2 -2
- package/dist/astro/routes/api/media/providers/_providerId_/index.mjs +2 -2
- package/dist/astro/routes/api/media/providers/index.mjs +2 -2
- package/dist/astro/routes/api/media/upload-url.mjs +13 -13
- package/dist/astro/routes/api/media.mjs +16 -16
- package/dist/astro/routes/api/menus/_name_/items/_id_.mjs +47 -36
- package/dist/astro/routes/api/menus/_name_/items.mjs +47 -36
- package/dist/astro/routes/api/menus/_name_/reorder.mjs +47 -36
- package/dist/astro/routes/api/menus/_name_/translations.mjs +47 -36
- package/dist/astro/routes/api/menus/_name_.mjs +47 -36
- package/dist/astro/routes/api/menus/index.mjs +47 -36
- package/dist/astro/routes/api/oauth/authorize.mjs +9 -7
- package/dist/astro/routes/api/oauth/device/authorize.mjs +7 -6
- package/dist/astro/routes/api/oauth/device/code.mjs +11 -9
- package/dist/astro/routes/api/oauth/device/token.mjs +10 -8
- package/dist/astro/routes/api/oauth/register.mjs +4 -4
- package/dist/astro/routes/api/oauth/token/refresh.mjs +7 -6
- package/dist/astro/routes/api/oauth/token/revoke.mjs +7 -6
- package/dist/astro/routes/api/oauth/token.mjs +8 -6
- package/dist/astro/routes/api/openapi.json.mjs +5 -5
- package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +4 -4
- package/dist/astro/routes/api/redirects/404s/index.mjs +15 -14
- package/dist/astro/routes/api/redirects/404s/summary.mjs +15 -14
- package/dist/astro/routes/api/redirects/_id_.mjs +47 -37
- package/dist/astro/routes/api/redirects/index.mjs +47 -37
- package/dist/astro/routes/api/revisions/_revisionId_/index.mjs +2 -2
- package/dist/astro/routes/api/revisions/_revisionId_/restore.mjs +2 -2
- package/dist/astro/routes/api/schema/collections/_slug_/fields/_fieldSlug_.mjs +65 -60
- package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +65 -60
- package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +65 -60
- package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +65 -60
- package/dist/astro/routes/api/schema/collections/index.mjs +65 -60
- package/dist/astro/routes/api/schema/index.mjs +12 -11
- package/dist/astro/routes/api/schema/orphans/_slug_.mjs +63 -58
- package/dist/astro/routes/api/schema/orphans/index.mjs +63 -58
- package/dist/astro/routes/api/search/enable.mjs +15 -14
- package/dist/astro/routes/api/search/index.mjs +14 -13
- package/dist/astro/routes/api/search/rebuild.mjs +15 -14
- package/dist/astro/routes/api/search/stats.mjs +9 -8
- package/dist/astro/routes/api/search/suggest.mjs +14 -13
- package/dist/astro/routes/api/sections/_slug_.mjs +47 -36
- package/dist/astro/routes/api/sections/index.mjs +47 -36
- package/dist/astro/routes/api/settings/email.mjs +5 -5
- package/dist/astro/routes/api/settings/reviews.mjs +11 -10
- package/dist/astro/routes/api/settings.mjs +47 -36
- package/dist/astro/routes/api/setup/admin-verify.mjs +14 -14
- package/dist/astro/routes/api/setup/admin.mjs +12 -12
- package/dist/astro/routes/api/setup/dev-bypass.mjs +35 -31
- package/dist/astro/routes/api/setup/dev-reset.mjs +2 -2
- package/dist/astro/routes/api/setup/index.mjs +37 -33
- package/dist/astro/routes/api/setup/status.mjs +3 -3
- package/dist/astro/routes/api/snapshot.mjs +11 -9
- package/dist/astro/routes/api/system/heartbeat.mjs +2 -2
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +50 -39
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +50 -39
- package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +50 -39
- package/dist/astro/routes/api/taxonomies/index.mjs +50 -39
- package/dist/astro/routes/api/themes/preview.mjs +8 -6
- package/dist/astro/routes/api/typegen.mjs +4 -4
- package/dist/astro/routes/api/well-known/auth.mjs +3 -3
- package/dist/astro/routes/api/well-known/oauth-authorization-server.mjs +3 -3
- package/dist/astro/routes/api/well-known/oauth-protected-resource.mjs +3 -3
- package/dist/astro/routes/api/widget-areas/_name_/reorder.mjs +46 -35
- package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +47 -36
- package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +47 -36
- package/dist/astro/routes/api/widget-areas/_name_.mjs +44 -33
- package/dist/astro/routes/api/widget-areas/index.mjs +47 -36
- package/dist/astro/routes/api/widget-components.mjs +2 -2
- package/dist/astro/routes/robots.txt.mjs +11 -10
- package/dist/astro/routes/sitemap-_collection_.xml.mjs +20 -18
- package/dist/astro/routes/sitemap.xml.mjs +19 -17
- package/dist/astro/session-driver.d.mts +1 -1
- package/dist/astro/session-driver.mjs +4 -4
- package/dist/astro/types.d.mts +13 -13
- package/dist/atomic-authority-CnBQJ14T.mjs +33 -0
- package/dist/{audit-CYjfxG9i.mjs → audit-F5iWkbcJ.mjs} +11 -4
- package/dist/auth/providers/github.d.mts +1 -1
- package/dist/auth/providers/google.d.mts +1 -1
- package/dist/{auth-control-guard-CITT8ZA_.mjs → auth-control-guard-DPOSBNFI.mjs} +1 -1
- package/dist/{authorize-KcI0pAfN.mjs → authorize-CXIjxIfC.mjs} +1 -1
- package/dist/{briefing-BgQTljQt.mjs → briefing-5zf0YZbR.mjs} +445 -447
- package/dist/{briefing-r3hXCDQC.mjs → briefing-DiupPvyN.mjs} +1 -1
- package/dist/{bundle-S6zx-V4D.mjs → bundle-DImnxo71.mjs} +3 -3
- package/dist/{byline-Ctil4rij.mjs → byline-DEZKlzD9.mjs} +107 -113
- package/dist/{byline-fields-51ja6JDa.d.mts → byline-fields-BO96fXLv.d.mts} +8 -8
- package/dist/{byline-fields-DiCyW6eQ.mjs → byline-fields-CY6V0ew1.mjs} +1 -1
- package/dist/{byline-fields-QpmruT5r.mjs → byline-fields-DGNKitg3.mjs} +3 -3
- package/dist/{byline-registry-rkr73qSE.mjs → byline-registry-CkuVVeJJ.mjs} +46 -76
- package/dist/{bylines-v_ZUQnR-.mjs → bylines-CXyKpVLQ.mjs} +6 -6
- package/dist/{bylines-BcuBpzVi.mjs → bylines-gSAfpHl4.mjs} +4 -4
- package/dist/{cache-V2BCplaY.mjs → cache-DZDOBJv3.mjs} +2 -2
- package/dist/{chunks-CnuL55JE.mjs → chunks-BnG3LPMN.mjs} +1 -1
- package/dist/cli/index.mjs +452 -263
- package/dist/cli/plugin-kit.d.mts +9 -9
- package/dist/cli/plugin-kit.mjs +2 -2
- package/dist/client/external-auth-headers.d.mts +1 -1
- package/dist/client/index.d.mts +11 -11
- package/dist/client/index.mjs +2 -2
- package/dist/{client-factory-C-y9VZDX.mjs → client-factory-6vLLT06O.mjs} +1 -1
- package/dist/{comment-_nvJSS-A.mjs → comment-kgLTdtQD.mjs} +15 -8
- package/dist/{comment-reaction-DhVgJ17S.mjs → comment-reaction-Cun5eIXL.mjs} +1 -1
- package/dist/{comments-D4mIDjvA.mjs → comments-ZYK_cZvx.mjs} +1 -1
- package/dist/{content-CVCrcuvD.mjs → content-D9xKUSno.mjs} +287 -165
- package/dist/{content-refresh-QvBIyb_g.mjs → content-refresh-9M9cc55-.mjs} +170 -193
- package/dist/{context-JjKucxBm.mjs → context-BU8AbLmY.mjs} +2 -2
- package/dist/{context-MftkHbWx.mjs → context-C5lPtfeh.mjs} +95 -77
- package/dist/{context-route-helpers-e1APrqSm.mjs → context-route-helpers-CWAHJFl3.mjs} +2 -2
- package/dist/{cron-mGVPQ5e6.mjs → cron-BVYo08mi.mjs} +36 -32
- package/dist/d1-binding-D6HZa3ks.mjs +8 -0
- package/dist/d1-dialect-BBxPg6Om.mjs +48 -0
- package/dist/{dashboard-ZJ7sMcBI.mjs → dashboard-BnD5krLg.mjs} +5 -5
- package/dist/database/batch.d.mts +22 -0
- package/dist/database/batch.mjs +92 -0
- package/dist/database/d1/index.d.mts +18 -0
- package/dist/database/d1/index.mjs +8 -0
- package/dist/db/d1.d.mts +7 -0
- package/dist/db/d1.mjs +13 -0
- package/dist/db/index.d.mts +4 -4
- package/dist/db/index.mjs +10 -7
- package/dist/db/libsql.d.mts +1 -1
- package/dist/db/libsql.mjs +46 -3
- package/dist/db/postgres.d.mts +1 -1
- package/dist/db/sqlite.d.mts +1 -1
- package/dist/{device-flow-eOcL5m0Q.mjs → device-flow-Prqg6ycD.mjs} +130 -94
- package/dist/{dialect-helpers-fk43GbDb.mjs → dialect-helpers-C6xtO-Ui.mjs} +1 -1
- package/dist/{discovery-CJkuHGhZ.mjs → discovery-CYcZJ1o3.mjs} +5 -5
- package/dist/{enrich-KErvJOuI.mjs → enrich-BjF-J4sF.mjs} +1 -1
- package/dist/{evidence-6IUv9ML3.mjs → evidence-krrA3uiG.mjs} +7 -7
- package/dist/{field-defs-cache-CwrIyZFT.mjs → field-defs-cache-BKKFFf_V.mjs} +5 -5
- package/dist/{forgeway-account-lYJ8iX3G.mjs → forgeway-account-CnWOIusE.mjs} +1 -1
- package/dist/{fts-manager-DX7ZkrCa.mjs → fts-manager-DA74x_uP.mjs} +72 -57
- package/dist/{hitl-requests-CmYVunm-.mjs → hitl-requests-CGjA1jND.mjs} +2 -2
- package/dist/{hitl-route-helpers-CRm537zS.mjs → hitl-route-helpers-BxSL0iZB.mjs} +5 -5
- package/dist/{import-DqRAgsKr.mjs → import-CayDCPaH.mjs} +9 -9
- package/dist/{index-Co7xtjkd.d.mts → index-mlJSqFkG.d.mts} +7 -4
- package/dist/index.d.mts +16 -16
- package/dist/index.mjs +103 -96
- package/dist/{integration-credentials-qudN6yRr.mjs → integration-credentials-Br16M1VE.mjs} +2 -2
- package/dist/{jsonld-BpvnSp2m.d.mts → jsonld-BUiFEiCZ.d.mts} +2 -2
- package/dist/{load-fCOciq0Q.mjs → load-B2oitobd.mjs} +1 -1
- package/dist/{loader-BDje8ME2.mjs → loader-Cgsx23wU.mjs} +4 -4
- package/dist/{manifest-schema-CfKD0thC.mjs → manifest-schema-DBXM_g8l.mjs} +1 -1
- package/dist/{mcp-reviewed-executor-DmhM3Cy6.mjs → mcp-reviewed-executor-RJ71uyQb.mjs} +7 -7
- package/dist/media/image-endpoint.mjs +1 -1
- package/dist/media/index.d.mts +1 -1
- package/dist/media/index.mjs +2 -2
- package/dist/media/local-runtime.d.mts +11 -11
- package/dist/media/local-runtime.mjs +3 -3
- package/dist/{media-dvRjj4po.mjs → media-BZqwtRTZ.mjs} +12 -4
- package/dist/{media-allowlist-DaG6lNoy.mjs → media-allowlist-CyByjUXh.mjs} +1 -1
- package/dist/{menus-CZbz5L_V.mjs → menus-2o-DVcwA.mjs} +8 -8
- package/dist/{menus-CpuR4Qkm.mjs → menus-5liJusbp.mjs} +138 -90
- package/dist/migrations-C7YXse7V.mjs +76 -0
- package/dist/oauth-authority-DOjME4Hh.mjs +43 -0
- package/dist/{oauth-authorization-Jf5e3azH.mjs → oauth-authorization-B_mmz7O2.mjs} +89 -98
- package/dist/{oauth-clients-tovQ4D4h.mjs → oauth-clients-Cr4pdIAE.mjs} +2 -2
- package/dist/object-cache/memory.d.mts +1 -1
- package/dist/{object-cache-D51qOseS.mjs → object-cache-BGjIlY9s.mjs} +1 -1
- package/dist/page/index.d.mts +10 -10
- package/dist/page/index.mjs +1 -1
- package/dist/{parse-IsGn-5lt.mjs → parse-BscLr3p2.mjs} +1 -1
- package/dist/plugin-utils.d.mts +9 -9
- package/dist/plugins/adapt-sandbox-entry.d.mts +9 -9
- package/dist/plugins/adapt-sandbox-entry.mjs +1 -1
- package/dist/{plugins-DXyLI3Hb.mjs → plugins-f48yrwfI.mjs} +35 -84
- package/dist/{policy-DKdNMv8y.mjs → policy-CrK1vl8l.mjs} +2 -2
- package/dist/{preview-BXmS1SXL.mjs → preview-E1xKZGsX.mjs} +2 -2
- package/dist/{provider-loader-DDq7R_RN.d.mts → provider-loader-H2wdGD0o.d.mts} +1 -1
- package/dist/{public-url-Ci7UbC0W.d.mts → public-url-CI700CW4.d.mts} +1 -1
- package/dist/{public-url-BQ9vf0AS.d.mts → public-url-zoO-QbN6.d.mts} +2 -2
- package/dist/{publication-authorization-C-vYPGD8.mjs → publication-authorization-Dq_20SZR.mjs} +458 -33
- package/dist/{query-DcB9uGTW.mjs → query-BkWWdxyb.mjs} +4 -4
- package/dist/{query-CrW2yI6G.mjs → query-D6oNo9iz.mjs} +15 -15
- package/dist/{rate-limit-DEkoxTsP.mjs → rate-limit-RaBJEgyt.mjs} +2 -2
- package/dist/{redirect-DG-o0CKV.mjs → redirect-HLI3wT5Y.mjs} +26 -14
- package/dist/{redirects-Bjp4iKJU.mjs → redirects-D16GFaOa.mjs} +5 -5
- package/dist/{redirects-N8gmWhVM.mjs → redirects-DpRiuRWn.mjs} +3 -3
- package/dist/{registry-D-IV_h50.mjs → registry-DcV93OL_.mjs} +183 -186
- package/dist/release-CZfAeyXm.mjs +5148 -0
- package/dist/request-context.d.mts +8 -0
- package/dist/{request-meta-BW0the1R.mjs → request-meta-C6yGqnGD.mjs} +1 -1
- package/dist/{resolve-pZ4NQM-X.mjs → resolve-CpOV2jt_.mjs} +1 -1
- package/dist/review-payload-LLIi1sxO.mjs +1386 -0
- package/dist/{review-requests-DICrYH2-.mjs → review-requests-BF2eEKr8.mjs} +93 -37
- package/dist/{review-requests-BTKfeWlS.mjs → review-requests-C7prIbCo.mjs} +2 -2
- package/dist/{review-route-helpers-DaZBBps8.mjs → review-route-helpers-BYx3Px90.mjs} +2 -2
- package/dist/{revision-De7OmYVD.mjs → revision-090sZyGc.mjs} +28 -22
- package/dist/revocation-DZ8e4JCS.mjs +53 -0
- package/dist/{runner-DJiRFyLI.mjs → runner-CVeq0266.mjs} +594 -491
- package/dist/{runner-Dye73myO.d.mts → runner-Cxl-vyk2.d.mts} +1 -1
- package/dist/{runs-DEujUDOj.mjs → runs-B8kCirJ6.mjs} +5 -5
- package/dist/runtime-env-v-1UXPAH.mjs +19 -0
- package/dist/runtime.d.mts +10 -10
- package/dist/runtime.mjs +5 -5
- package/dist/schema-DFeC5axi.mjs +8 -0
- package/dist/{search-DxUKN9Zz.mjs → search-C9qOBgvo.mjs} +4 -4
- package/dist/{secrets-AdCrGg1c.mjs → secrets-BP2YTPWn.mjs} +10 -11
- package/dist/{sections-BPFOEMK6.mjs → sections-CkoQY7Z9.mjs} +2 -2
- package/dist/seed/index.d.mts +2 -2
- package/dist/seed/index.mjs +29 -25
- package/dist/seo/index.d.mts +3 -3
- package/dist/seo/index.mjs +11 -10
- package/dist/{seo-GfovzqpU.mjs → seo-Bypxm1iD.mjs} +1 -1
- package/dist/{seo-DWHdo5aW.mjs → seo-DYpc_rQ1.mjs} +25 -15
- package/dist/{service-BrNKVCjC.mjs → service-DOFqfUVv.mjs} +46 -21
- package/dist/{service-DbgjHWyW.mjs → service-mJBl4ZP4.mjs} +2 -2
- package/dist/{session-user-D8WwGEPH.mjs → session-user-DacoiKrJ.mjs} +1 -1
- package/dist/{settings-BKEHw6Bu.mjs → settings-2p7TuNWG.mjs} +2 -2
- package/dist/{settings-CAsQLi0N.mjs → settings-DRFy8JQx.mjs} +8 -8
- package/dist/{setup-complete-CHCYS5KV.mjs → setup-complete-CWMnrNFN.mjs} +1 -1
- package/dist/{site-activity-7oezuHXK.mjs → site-activity-BrN2NviL.mjs} +11 -4
- package/dist/{site-context-CA7rbxux.mjs → site-context-D9oETfxF.mjs} +50 -37
- package/dist/{site-url-DoZf_jVj.mjs → site-url-DoTPKRND.mjs} +1 -1
- package/dist/state-D8AogXCV.mjs +30 -0
- package/dist/storage/local.d.mts +1 -1
- package/dist/storage/local.mjs +1 -1
- package/dist/storage/s3.d.mts +1 -1
- package/dist/storage/s3.mjs +3 -3
- package/dist/{store-c4qx3gVh.mjs → store-CjmmGlVw.mjs} +37 -12
- package/dist/submission-BLvkvewK.mjs +411 -0
- package/dist/{taxonomies-ALDiRQ84.mjs → taxonomies-C5ayPp3T.mjs} +3 -3
- package/dist/{taxonomies-93DV-1QT.mjs → taxonomies-DW6Fps-w.mjs} +7 -7
- package/dist/{taxonomy-BOBTJ_aE.mjs → taxonomy-DWxxLpp5.mjs} +3 -3
- package/dist/{tokens-c-qxNqzC.mjs → tokens-I3tSjoFI.mjs} +1 -1
- package/dist/{trusted-proxy-CdEl6g6B.mjs → trusted-proxy-CvDP0g0F.mjs} +4 -12
- package/dist/{types-6KmeXInJ.d.mts → types-BFoQ5a1v.d.mts} +1 -1
- package/dist/{types-BpSTdH1H.mjs → types-BqxIv8Il.mjs} +2 -2
- package/dist/{types-BRCUO8NR.d.mts → types-CVRNRAA5.d.mts} +1 -0
- package/dist/{types-CfpX1og5.d.mts → types-Tt_IGMno.d.mts} +360 -172
- package/dist/ui/server-runtime.d.mts +13 -13
- package/dist/ui/server-runtime.mjs +28 -26
- package/dist/{user-D0NJ7gYf.mjs → user-1-YV30lf.mjs} +2 -2
- package/dist/{utils-BK2efsHv.mjs → utils-BoWkoty8.mjs} +2 -2
- package/dist/{validate-CDWVODvc.d.mts → validate-CCOsvPg2.d.mts} +3 -3
- package/dist/{validate-C9g9iX3q.mjs → validate-CupwWNWL.mjs} +3 -3
- package/dist/version-DpT-k_Ny.mjs +6 -0
- package/dist/{widgets-Cm5Qx2Np.mjs → widgets-DbOctkXv.mjs} +3 -3
- package/dist/{wordpress-slugs-WdPZaVXf.mjs → wordpress-slugs-pQlLXbKn.mjs} +1 -1
- package/dist/{worker-Bhuu7eqS.mjs → worker-wjRq4FI9.mjs} +76 -47
- package/dist/workers-build-QVrquLLe.mjs +36 -0
- package/dist/{zod-generator-DS5oZNaL.mjs → zod-generator-BzACAoR5.mjs} +2 -2
- package/package.json +34 -8
- package/dist/after-BfniwgIf.mjs +0 -9
- package/dist/api-tokens-CmT83Bgj.mjs +0 -3
- package/dist/db/libsql-http.d.mts +0 -27
- package/dist/db/libsql-http.mjs +0 -29
- package/dist/libsql-dialect-CANq6UNI.mjs +0 -47
- package/dist/oauth-user-lookup-B451pZmd.mjs +0 -25
- package/dist/review-payload-f1L4lzQg.mjs +0 -111
- package/dist/revocation-CkTOhdlw.mjs +0 -42
- package/dist/schema-IjuRxkqq.mjs +0 -8
- package/dist/submission-C47cHBIg.mjs +0 -67
- package/dist/transaction-BGQgnwUi.mjs +0 -28
- package/dist/version-CJqc1mwj.mjs +0 -6
- /package/dist/{base64-F8-DUraK.mjs → base64-Cz-aU0X1.mjs} +0 -0
- /package/dist/{challenge-store-CDKfye2r.mjs → challenge-store-DFGsDtCj.mjs} +0 -0
- /package/dist/{components-DAq_4iPX.mjs → components-gMTtJqHg.mjs} +0 -0
- /package/dist/{config-CVssduLe.mjs → config-XW5tMrH8.mjs} +0 -0
- /package/dist/{content-index-names-Bbu1FY1r.mjs → content-index-names-CDc2IQIx.mjs} +0 -0
- /package/dist/{context-types-CPWAJRs5.mjs → context-types-DLD_HnKT.mjs} +0 -0
- /package/dist/{default-BeIzUa1e.mjs → default-w3MwLng7.mjs} +0 -0
- /package/dist/{email-console-Bfi_exVg.mjs → email-console-CpvgEN1w.mjs} +0 -0
- /package/dist/{error-DLg1H2LT.mjs → error-B-44r5TD.mjs} +0 -0
- /package/dist/{escape-C6lkys0j.mjs → escape-B1GM0yJU.mjs} +0 -0
- /package/dist/{experimental-workflows-B9x8delL.mjs → experimental-workflows-fzJHB3ZI.mjs} +0 -0
- /package/dist/{hash-jhbF98tT.mjs → hash-DvMZXj2L.mjs} +0 -0
- /package/dist/{media-url-CL3NzgLh.mjs → media-url-D-elxQjL.mjs} +0 -0
- /package/dist/{mime-CDTtL7jE.mjs → mime-D_ae-u_U.mjs} +0 -0
- /package/dist/{mode-DJeacFCZ.mjs → mode-BJwb_MgK.mjs} +0 -0
- /package/dist/{normalize-Ev3FiBMx.mjs → normalize-5rct_U0I.mjs} +0 -0
- /package/dist/{oauth-state-store-Do1a_o3H.mjs → oauth-state-store-D2H9hKcN.mjs} +0 -0
- /package/dist/{options-1dBRkoCl.mjs → options-BcqHWpc-.mjs} +0 -0
- /package/dist/{output-8j9oltTf.mjs → output-CdmbQioY.mjs} +0 -0
- /package/dist/{parser-C9rzPuSZ.mjs → parser-ehIlj32k.mjs} +0 -0
- /package/dist/{passkey-config-CRN44T04.mjs → passkey-config-sUQoLEj_.mjs} +0 -0
- /package/dist/{patterns-3XE9bU4r.mjs → patterns-CZ7D4y_R.mjs} +0 -0
- /package/dist/{placeholder-D03pGvqM.d.mts → placeholder-CQKI6vLd.d.mts} +0 -0
- /package/dist/{portable-text-BdRm4uZq.d.mts → portable-text-BE7nszX6.d.mts} +0 -0
- /package/dist/{portable-text-tIk9_uz_.mjs → portable-text-DH3Om_2D.mjs} +0 -0
- /package/dist/{process-cache-B-L-A9zg.mjs → process-cache-MHM4Sqzs.mjs} +0 -0
- /package/dist/{provider-loader-C4i82ll1.mjs → provider-loader-Dnv2neOu.mjs} +0 -0
- /package/dist/{public-discovery-CyDzK1-S.mjs → public-discovery-CTql6jdZ.mjs} +0 -0
- /package/dist/{public-url-BVIjzMo3.mjs → public-url-4sMO36Gw.mjs} +0 -0
- /package/dist/{public-url-oudwI7K0.mjs → public-url-DNt9A1yS.mjs} +0 -0
- /package/dist/{redirect-Dp5u-8dH.mjs → redirect-Cjjb5VYr.mjs} +0 -0
- /package/dist/{request-cache-BruBnFAR.mjs → request-cache-DPmV5nk4.mjs} +0 -0
- /package/dist/{seo-contributions-BAtRDXEQ.mjs → seo-contributions-atY3jZEV.mjs} +0 -0
- /package/dist/{service-DeX1PRNt.mjs → service-CeEi6nax.mjs} +0 -0
- /package/dist/{setup-nonce-D-CEYlw7.mjs → setup-nonce-BUmfCiY1.mjs} +0 -0
- /package/dist/{sidecar-client-Bw2C0XTf.mjs → sidecar-client-CbrX8nuw.mjs} +0 -0
- /package/dist/{slugify-KSsVD_D3.mjs → slugify-Di8Q_MFq.mjs} +0 -0
- /package/dist/{ssrf-C7tTSD1r.mjs → ssrf-COxLChKv.mjs} +0 -0
- /package/dist/{stable-hash-DF7R5eN8.mjs → stable-hash-DEtJgcp7.mjs} +0 -0
- /package/dist/{status-Bba6RbkS.mjs → status-DBSB6tdS.mjs} +0 -0
- /package/dist/{transport-ktLL9r2O.d.mts → transport-CZbtxgKZ.d.mts} +0 -0
- /package/dist/{transport-BddGhTAI.mjs → transport-aPKvM53n.mjs} +0 -0
- /package/dist/{types-CKIt_jmM.d.mts → types-1qU0-N1P.d.mts} +0 -0
- /package/dist/{types-BQZFeZjd.mjs → types-BKsk4nnM.mjs} +0 -0
- /package/dist/{types-CLMOusxP.d.mts → types-BWsEjujW.d.mts} +0 -0
- /package/dist/{types--3oJQ0hs.d.mts → types-CAD4OvmF.d.mts} +0 -0
- /package/dist/{types-BbkkkAb6.mjs → types-ChSk0dmw.mjs} +0 -0
- /package/dist/{types-C0DPvhR5.mjs → types-CyBH89BS.mjs} +0 -0
- /package/dist/{types-CU3Wn2HC.d.mts → types-DNPP-eu4.d.mts} +0 -0
- /package/dist/{types-CPaVj_GC.d.mts → types-SddyDti7.d.mts} +0 -0
- /package/dist/{url-C_pLSrGZ.mjs → url-Ce0qtSdB.mjs} +0 -0
- /package/dist/{url-Dumsft7G.mjs → url-DfqolpO2.mjs} +0 -0
- /package/dist/{validate-VPnKoIzW.mjs → validate-Co3j6T_K.mjs} +0 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
1
|
+
import { n as d1Database } from "./d1-binding-D6HZa3ks.mjs";
|
|
2
|
+
import { atomicBatch, ensureAtomicBatchSchema } from "./database/batch.mjs";
|
|
3
|
+
import { t as validateIdentifier } from "./validate-Co3j6T_K.mjs";
|
|
4
|
+
import { a as currentTimestampValue, i as currentTimestamp$1, l as listTablesLike, n as columnExists, s as isSqlite, t as binaryType } from "./dialect-helpers-C6xtO-Ui.mjs";
|
|
5
|
+
import { n as getI18nConfig } from "./config-XW5tMrH8.mjs";
|
|
6
|
+
import { n as contentLocaleUpdatedIndexName, t as contentLocaleCreatedIndexName } from "./content-index-names-CDc2IQIx.mjs";
|
|
5
7
|
import { createRequire } from "node:module";
|
|
6
|
-
import { createHash } from "node:crypto";
|
|
8
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
7
9
|
import { Migrator, sql } from "kysely";
|
|
8
10
|
|
|
9
11
|
//#region \0rolldown/runtime.js
|
|
@@ -22,11 +24,94 @@ var __exportAll = (all, no_symbols) => {
|
|
|
22
24
|
return target;
|
|
23
25
|
};
|
|
24
26
|
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/database/d1-migrations.ts
|
|
29
|
+
const LEASE_MS = 5 * 6e4;
|
|
30
|
+
async function assertD1Migrations(db, table, names) {
|
|
31
|
+
validateIdentifier(table.startsWith("_") ? table.slice(1) : table, "migration table");
|
|
32
|
+
let applied;
|
|
33
|
+
try {
|
|
34
|
+
applied = (await sql`SELECT name FROM ${sql.ref(table)} ORDER BY name`.execute(db)).rows.map((row) => row.name);
|
|
35
|
+
} catch (cause) {
|
|
36
|
+
throw new Error("D1 schema is not installed. Apply migrations before serving requests.", { cause });
|
|
37
|
+
}
|
|
38
|
+
if (JSON.stringify(applied) !== JSON.stringify(names.toSorted())) throw new Error("D1 schema does not match this release. Apply migrations before serving requests.");
|
|
39
|
+
}
|
|
40
|
+
/** Run only from an explicit deployment or maintenance operation. */
|
|
41
|
+
async function migrateD1(db, table, migrations, options = {}) {
|
|
42
|
+
if (!d1Database(db)) throw new Error("migrateD1 requires a Dineway D1 database.");
|
|
43
|
+
validateIdentifier(table.startsWith("_") ? table.slice(1) : table, "migration table");
|
|
44
|
+
const ordered = migrations.toSorted((left, right) => left.name === right.name ? 0 : left.name < right.name ? -1 : 1);
|
|
45
|
+
if (new Set(ordered.map((migration) => migration.name)).size !== ordered.length) throw new Error("Duplicate D1 migration name.");
|
|
46
|
+
if (options.adopt && (!options.adopt.checks.length || !ordered.some((item) => item.name === options.adopt.through))) throw new Error("D1 adoption requires a known migration and schema/history checks.");
|
|
47
|
+
await ensureAtomicBatchSchema(db);
|
|
48
|
+
await atomicBatch(db, { statements: [
|
|
49
|
+
sql`CREATE TABLE IF NOT EXISTS ${sql.ref(table)} (name TEXT PRIMARY KEY, timestamp TEXT NOT NULL)`.compile(db),
|
|
50
|
+
sql`CREATE TABLE IF NOT EXISTS _dineway_d1_migration_checksums (namespace TEXT NOT NULL, name TEXT NOT NULL, checksum TEXT NOT NULL, PRIMARY KEY(namespace, name))`.compile(db),
|
|
51
|
+
sql`CREATE TABLE IF NOT EXISTS _dineway_d1_migration_leases (namespace TEXT PRIMARY KEY, token TEXT NOT NULL, expires_at INTEGER NOT NULL)`.compile(db)
|
|
52
|
+
] });
|
|
53
|
+
const token = randomUUID();
|
|
54
|
+
const now = Date.now();
|
|
55
|
+
if ((await sql`INSERT INTO _dineway_d1_migration_leases (namespace, token, expires_at)
|
|
56
|
+
VALUES (${table}, ${token}, ${now + LEASE_MS})
|
|
57
|
+
ON CONFLICT(namespace) DO UPDATE SET token = excluded.token, expires_at = excluded.expires_at
|
|
58
|
+
WHERE _dineway_d1_migration_leases.expires_at <= ${now}
|
|
59
|
+
RETURNING token`.execute(db)).rows[0]?.token !== token) throw new Error("Another D1 migration is running.");
|
|
60
|
+
try {
|
|
61
|
+
const applied = await sql`SELECT m.name, c.checksum FROM ${sql.ref(table)} m
|
|
62
|
+
LEFT JOIN _dineway_d1_migration_checksums c ON c.namespace = ${table} AND c.name = m.name ORDER BY m.name`.execute(db);
|
|
63
|
+
const checksums = ordered.map((migration) => createHash("sha256").update(JSON.stringify(migration.statements.map((statement) => ({
|
|
64
|
+
sql: statement.sql,
|
|
65
|
+
parameters: statement.parameters
|
|
66
|
+
})))).digest("hex"));
|
|
67
|
+
const adoptionEnd = options.adopt ? ordered.findIndex((item) => item.name === options.adopt.through) + 1 : 0;
|
|
68
|
+
for (const [index, previous] of applied.rows.entries()) if (ordered[index]?.name !== previous.name || previous.checksum !== checksums[index] && !(previous.checksum === null && index < adoptionEnd)) throw new Error("D1 migration history differs from this release. Refusing to replay or adopt unverified migrations.");
|
|
69
|
+
const completed = [];
|
|
70
|
+
let start = applied.rows.length;
|
|
71
|
+
if (options.adopt) {
|
|
72
|
+
const time = Date.now();
|
|
73
|
+
await atomicBatch(db, {
|
|
74
|
+
checks: [
|
|
75
|
+
...options.checks ?? [],
|
|
76
|
+
...options.adopt.checks,
|
|
77
|
+
sql`EXISTS (SELECT 1 FROM _dineway_d1_migration_leases WHERE namespace = ${table} AND token = ${token} AND expires_at > ${time})`
|
|
78
|
+
],
|
|
79
|
+
statements: ordered.slice(0, adoptionEnd).flatMap((migration, index) => {
|
|
80
|
+
const previous = applied.rows[index];
|
|
81
|
+
return [...!previous ? [sql`INSERT INTO ${sql.ref(table)} (name, timestamp) VALUES (${migration.name}, ${new Date(time).toISOString()})`.compile(db)] : [], ...!previous?.checksum ? [sql`INSERT INTO _dineway_d1_migration_checksums (namespace, name, checksum) VALUES (${table}, ${migration.name}, ${checksums[index]})`.compile(db)] : []];
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
start = Math.max(start, adoptionEnd);
|
|
85
|
+
}
|
|
86
|
+
for (let index = start; index < ordered.length; index++) {
|
|
87
|
+
const migration = ordered[index];
|
|
88
|
+
const time = Date.now();
|
|
89
|
+
await atomicBatch(db, {
|
|
90
|
+
checks: [
|
|
91
|
+
...options.checks ?? [],
|
|
92
|
+
...migration.checks ?? [],
|
|
93
|
+
sql`EXISTS (SELECT 1 FROM _dineway_d1_migration_leases WHERE namespace = ${table} AND token = ${token} AND expires_at > ${time})`
|
|
94
|
+
],
|
|
95
|
+
statements: [
|
|
96
|
+
...migration.statements,
|
|
97
|
+
sql`INSERT INTO ${sql.ref(table)} (name, timestamp) VALUES (${migration.name}, ${new Date(time).toISOString()})`.compile(db),
|
|
98
|
+
sql`INSERT INTO _dineway_d1_migration_checksums (namespace, name, checksum) VALUES (${table}, ${migration.name}, ${checksums[index]})`.compile(db),
|
|
99
|
+
sql`UPDATE _dineway_d1_migration_leases SET expires_at = ${time + LEASE_MS} WHERE namespace = ${table} AND token = ${token}`.compile(db)
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
completed.push(migration.name);
|
|
103
|
+
}
|
|
104
|
+
return completed;
|
|
105
|
+
} finally {
|
|
106
|
+
await sql`DELETE FROM _dineway_d1_migration_leases WHERE namespace = ${table} AND token = ${token}`.execute(db);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
25
110
|
//#endregion
|
|
26
111
|
//#region src/database/migrations/001_initial.ts
|
|
27
112
|
var _001_initial_exports = /* @__PURE__ */ __exportAll({
|
|
28
|
-
down: () => down$
|
|
29
|
-
up: () => up$
|
|
113
|
+
down: () => down$121,
|
|
114
|
+
up: () => up$121
|
|
30
115
|
});
|
|
31
116
|
/**
|
|
32
117
|
* Initial schema migration
|
|
@@ -35,7 +120,7 @@ var _001_initial_exports = /* @__PURE__ */ __exportAll({
|
|
|
35
120
|
* by the SchemaRegistry when collections are added via the admin UI.
|
|
36
121
|
* This migration only creates system tables.
|
|
37
122
|
*/
|
|
38
|
-
async function up$
|
|
123
|
+
async function up$121(db) {
|
|
39
124
|
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
125
|
await db.schema.createIndex("idx_revisions_entry").ifNotExists().on("revisions").columns(["collection", "entry_id"]).execute();
|
|
41
126
|
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 +140,7 @@ async function up$120(db) {
|
|
|
55
140
|
await db.schema.createIndex("idx_audit_action").ifNotExists().on("audit_logs").column("action").execute();
|
|
56
141
|
await db.schema.createIndex("idx_audit_timestamp").ifNotExists().on("audit_logs").column("timestamp").execute();
|
|
57
142
|
}
|
|
58
|
-
async function down$
|
|
143
|
+
async function down$121(db) {
|
|
59
144
|
await db.schema.dropTable("audit_logs").execute();
|
|
60
145
|
await db.schema.dropTable("options").execute();
|
|
61
146
|
await db.schema.dropTable("users").execute();
|
|
@@ -68,26 +153,26 @@ async function down$120(db) {
|
|
|
68
153
|
//#endregion
|
|
69
154
|
//#region src/database/migrations/002_media_status.ts
|
|
70
155
|
var _002_media_status_exports = /* @__PURE__ */ __exportAll({
|
|
71
|
-
down: () => down$
|
|
72
|
-
up: () => up$
|
|
156
|
+
down: () => down$120,
|
|
157
|
+
up: () => up$120
|
|
73
158
|
});
|
|
74
159
|
/**
|
|
75
160
|
* Add status column to media table for tracking upload state.
|
|
76
161
|
* Status values: 'pending' | 'ready' | 'failed'
|
|
77
162
|
*/
|
|
78
|
-
async function up$
|
|
163
|
+
async function up$120(db) {
|
|
79
164
|
await db.schema.alterTable("media").addColumn("status", "text", (col) => col.notNull().defaultTo("ready")).execute();
|
|
80
165
|
await db.schema.createIndex("idx_media_status").on("media").column("status").execute();
|
|
81
166
|
}
|
|
82
|
-
async function down$
|
|
167
|
+
async function down$120(db) {
|
|
83
168
|
await db.schema.dropIndex("idx_media_status").execute();
|
|
84
169
|
}
|
|
85
170
|
|
|
86
171
|
//#endregion
|
|
87
172
|
//#region src/database/migrations/003_schema_registry.ts
|
|
88
173
|
var _003_schema_registry_exports = /* @__PURE__ */ __exportAll({
|
|
89
|
-
down: () => down$
|
|
90
|
-
up: () => up$
|
|
174
|
+
down: () => down$119,
|
|
175
|
+
up: () => up$119
|
|
91
176
|
});
|
|
92
177
|
/**
|
|
93
178
|
* Migration: Schema Registry Tables
|
|
@@ -95,14 +180,14 @@ var _003_schema_registry_exports = /* @__PURE__ */ __exportAll({
|
|
|
95
180
|
* Creates the schema registry tables that store collection and field definitions.
|
|
96
181
|
* This enables dynamic schema management where the database is the source of truth.
|
|
97
182
|
*/
|
|
98
|
-
async function up$
|
|
183
|
+
async function up$119(db) {
|
|
99
184
|
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
185
|
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
186
|
await db.schema.createIndex("idx_fields_collection_slug").on("_dineway_fields").columns(["collection_id", "slug"]).unique().execute();
|
|
102
187
|
await db.schema.createIndex("idx_fields_collection").on("_dineway_fields").column("collection_id").execute();
|
|
103
188
|
await db.schema.createIndex("idx_fields_sort").on("_dineway_fields").columns(["collection_id", "sort_order"]).execute();
|
|
104
189
|
}
|
|
105
|
-
async function down$
|
|
190
|
+
async function down$119(db) {
|
|
106
191
|
await db.schema.dropTable("_dineway_fields").execute();
|
|
107
192
|
await db.schema.dropTable("_dineway_collections").execute();
|
|
108
193
|
}
|
|
@@ -110,8 +195,8 @@ async function down$118(db) {
|
|
|
110
195
|
//#endregion
|
|
111
196
|
//#region src/database/migrations/004_plugins.ts
|
|
112
197
|
var _004_plugins_exports = /* @__PURE__ */ __exportAll({
|
|
113
|
-
down: () => down$
|
|
114
|
-
up: () => up$
|
|
198
|
+
down: () => down$118,
|
|
199
|
+
up: () => up$118
|
|
115
200
|
});
|
|
116
201
|
/**
|
|
117
202
|
* Migration: Plugin System Tables
|
|
@@ -121,7 +206,7 @@ var _004_plugins_exports = /* @__PURE__ */ __exportAll({
|
|
|
121
206
|
*
|
|
122
207
|
* @see PLUGIN-SYSTEM.md § Plugin Storage
|
|
123
208
|
*/
|
|
124
|
-
async function up$
|
|
209
|
+
async function up$118(db) {
|
|
125
210
|
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
211
|
"plugin_id",
|
|
127
212
|
"collection",
|
|
@@ -139,7 +224,7 @@ async function up$117(db) {
|
|
|
139
224
|
"index_name"
|
|
140
225
|
]).execute();
|
|
141
226
|
}
|
|
142
|
-
async function down$
|
|
227
|
+
async function down$118(db) {
|
|
143
228
|
await db.schema.dropTable("_plugin_indexes").execute();
|
|
144
229
|
await db.schema.dropTable("_plugin_state").execute();
|
|
145
230
|
await db.schema.dropTable("_plugin_storage").execute();
|
|
@@ -148,8 +233,8 @@ async function down$117(db) {
|
|
|
148
233
|
//#endregion
|
|
149
234
|
//#region src/database/migrations/005_menus.ts
|
|
150
235
|
var _005_menus_exports = /* @__PURE__ */ __exportAll({
|
|
151
|
-
down: () => down$
|
|
152
|
-
up: () => up$
|
|
236
|
+
down: () => down$117,
|
|
237
|
+
up: () => up$117
|
|
153
238
|
});
|
|
154
239
|
/**
|
|
155
240
|
* Navigation Menus migration
|
|
@@ -157,13 +242,13 @@ var _005_menus_exports = /* @__PURE__ */ __exportAll({
|
|
|
157
242
|
* Creates tables for admin-editable navigation menus.
|
|
158
243
|
* Menu items can reference content entries, taxonomy terms, or custom URLs.
|
|
159
244
|
*/
|
|
160
|
-
async function up$
|
|
245
|
+
async function up$117(db) {
|
|
161
246
|
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
247
|
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
248
|
await db.schema.createIndex("idx_menu_items_menu").on("_dineway_menu_items").columns(["menu_id", "sort_order"]).execute();
|
|
164
249
|
await db.schema.createIndex("idx_menu_items_parent").on("_dineway_menu_items").column("parent_id").execute();
|
|
165
250
|
}
|
|
166
|
-
async function down$
|
|
251
|
+
async function down$117(db) {
|
|
167
252
|
await db.schema.dropTable("_dineway_menu_items").execute();
|
|
168
253
|
await db.schema.dropTable("_dineway_menus").execute();
|
|
169
254
|
}
|
|
@@ -171,8 +256,8 @@ async function down$116(db) {
|
|
|
171
256
|
//#endregion
|
|
172
257
|
//#region src/database/migrations/006_taxonomy_defs.ts
|
|
173
258
|
var _006_taxonomy_defs_exports = /* @__PURE__ */ __exportAll({
|
|
174
|
-
down: () => down$
|
|
175
|
-
up: () => up$
|
|
259
|
+
down: () => down$116,
|
|
260
|
+
up: () => up$116
|
|
176
261
|
});
|
|
177
262
|
/**
|
|
178
263
|
* Taxonomy definitions migration
|
|
@@ -180,7 +265,7 @@ var _006_taxonomy_defs_exports = /* @__PURE__ */ __exportAll({
|
|
|
180
265
|
* Adds _dineway_taxonomy_defs table to store taxonomy definitions (category, tag, custom)
|
|
181
266
|
* and seeds default category and tag taxonomies.
|
|
182
267
|
*/
|
|
183
|
-
async function up$
|
|
268
|
+
async function up$116(db) {
|
|
184
269
|
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
270
|
await db.insertInto("_dineway_taxonomy_defs").values([{
|
|
186
271
|
id: "taxdef_category",
|
|
@@ -198,22 +283,22 @@ async function up$115(db) {
|
|
|
198
283
|
collections: JSON.stringify(["posts"])
|
|
199
284
|
}]).execute();
|
|
200
285
|
}
|
|
201
|
-
async function down$
|
|
286
|
+
async function down$116(db) {
|
|
202
287
|
await db.schema.dropTable("_dineway_taxonomy_defs").execute();
|
|
203
288
|
}
|
|
204
289
|
|
|
205
290
|
//#endregion
|
|
206
291
|
//#region src/database/migrations/007_widgets.ts
|
|
207
292
|
var _007_widgets_exports = /* @__PURE__ */ __exportAll({
|
|
208
|
-
down: () => down$
|
|
209
|
-
up: () => up$
|
|
293
|
+
down: () => down$115,
|
|
294
|
+
up: () => up$115
|
|
210
295
|
});
|
|
211
|
-
async function up$
|
|
296
|
+
async function up$115(db) {
|
|
212
297
|
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
298
|
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
299
|
await db.schema.createIndex("idx_widgets_area").on("_dineway_widgets").columns(["area_id", "sort_order"]).execute();
|
|
215
300
|
}
|
|
216
|
-
async function down$
|
|
301
|
+
async function down$115(db) {
|
|
217
302
|
await db.schema.dropTable("_dineway_widgets").execute();
|
|
218
303
|
await db.schema.dropTable("_dineway_widget_areas").execute();
|
|
219
304
|
}
|
|
@@ -221,8 +306,8 @@ async function down$114(db) {
|
|
|
221
306
|
//#endregion
|
|
222
307
|
//#region src/database/migrations/008_auth.ts
|
|
223
308
|
var _008_auth_exports = /* @__PURE__ */ __exportAll({
|
|
224
|
-
down: () => down$
|
|
225
|
-
up: () => up$
|
|
309
|
+
down: () => down$114,
|
|
310
|
+
up: () => up$114
|
|
226
311
|
});
|
|
227
312
|
/**
|
|
228
313
|
* Auth migration - passkey-first authentication
|
|
@@ -236,7 +321,7 @@ var _008_auth_exports = /* @__PURE__ */ __exportAll({
|
|
|
236
321
|
* - Creates oauth_accounts table (external provider links)
|
|
237
322
|
* - Creates allowed_domains table (self-signup)
|
|
238
323
|
*/
|
|
239
|
-
async function up$
|
|
324
|
+
async function up$114(db) {
|
|
240
325
|
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
326
|
await sql`
|
|
242
327
|
INSERT INTO users_new (id, email, name, role, data, created_at, updated_at)
|
|
@@ -269,7 +354,7 @@ async function up$113(db) {
|
|
|
269
354
|
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
355
|
await db.schema.createIndex("idx_auth_challenges_expires").on("auth_challenges").column("expires_at").execute();
|
|
271
356
|
}
|
|
272
|
-
async function down$
|
|
357
|
+
async function down$114(db) {
|
|
273
358
|
await db.schema.dropTable("auth_challenges").execute();
|
|
274
359
|
await db.schema.dropTable("allowed_domains").execute();
|
|
275
360
|
await db.schema.dropTable("oauth_accounts").execute();
|
|
@@ -302,8 +387,8 @@ async function down$113(db) {
|
|
|
302
387
|
//#endregion
|
|
303
388
|
//#region src/database/migrations/009_user_disabled.ts
|
|
304
389
|
var _009_user_disabled_exports = /* @__PURE__ */ __exportAll({
|
|
305
|
-
down: () => down$
|
|
306
|
-
up: () => up$
|
|
390
|
+
down: () => down$113,
|
|
391
|
+
up: () => up$113
|
|
307
392
|
});
|
|
308
393
|
/**
|
|
309
394
|
* User disabled column - for soft-disabling users
|
|
@@ -312,19 +397,19 @@ var _009_user_disabled_exports = /* @__PURE__ */ __exportAll({
|
|
|
312
397
|
* - Adds disabled column to users table (INTEGER, default 0)
|
|
313
398
|
* - Disabled users cannot log in
|
|
314
399
|
*/
|
|
315
|
-
async function up$
|
|
400
|
+
async function up$113(db) {
|
|
316
401
|
await sql`ALTER TABLE users ADD COLUMN disabled INTEGER NOT NULL DEFAULT 0`.execute(db);
|
|
317
402
|
await db.schema.createIndex("idx_users_disabled").on("users").column("disabled").execute();
|
|
318
403
|
}
|
|
319
|
-
async function down$
|
|
404
|
+
async function down$113(db) {
|
|
320
405
|
await db.schema.dropIndex("idx_users_disabled").execute();
|
|
321
406
|
}
|
|
322
407
|
|
|
323
408
|
//#endregion
|
|
324
409
|
//#region src/database/migrations/011_sections.ts
|
|
325
410
|
var _011_sections_exports = /* @__PURE__ */ __exportAll({
|
|
326
|
-
down: () => down$
|
|
327
|
-
up: () => up$
|
|
411
|
+
down: () => down$112,
|
|
412
|
+
up: () => up$112
|
|
328
413
|
});
|
|
329
414
|
/**
|
|
330
415
|
* Migration: Add sections tables and performance indexes
|
|
@@ -333,13 +418,13 @@ var _011_sections_exports = /* @__PURE__ */ __exportAll({
|
|
|
333
418
|
* They provide a library of pre-built page sections (heroes, CTAs, testimonials, etc.)
|
|
334
419
|
* that content authors can browse and insert with a single click.
|
|
335
420
|
*/
|
|
336
|
-
async function up$
|
|
421
|
+
async function up$112(db) {
|
|
337
422
|
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
423
|
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
424
|
await db.schema.createIndex("idx_sections_category").on("_dineway_sections").columns(["category_id"]).execute();
|
|
340
425
|
await db.schema.createIndex("idx_sections_source").on("_dineway_sections").columns(["source"]).execute();
|
|
341
426
|
}
|
|
342
|
-
async function down$
|
|
427
|
+
async function down$112(db) {
|
|
343
428
|
await db.schema.dropIndex("idx_sections_source").execute();
|
|
344
429
|
await db.schema.dropIndex("idx_sections_category").execute();
|
|
345
430
|
await db.schema.dropTable("_dineway_sections").execute();
|
|
@@ -349,8 +434,8 @@ async function down$111(db) {
|
|
|
349
434
|
//#endregion
|
|
350
435
|
//#region src/database/migrations/012_search.ts
|
|
351
436
|
var _012_search_exports = /* @__PURE__ */ __exportAll({
|
|
352
|
-
down: () => down$
|
|
353
|
-
up: () => up$
|
|
437
|
+
down: () => down$111,
|
|
438
|
+
up: () => up$111
|
|
354
439
|
});
|
|
355
440
|
/**
|
|
356
441
|
* Migration: Search Support
|
|
@@ -358,11 +443,11 @@ var _012_search_exports = /* @__PURE__ */ __exportAll({
|
|
|
358
443
|
* Adds search configuration to collections and searchable flag to fields.
|
|
359
444
|
* FTS5 tables are created dynamically when search is enabled for a collection.
|
|
360
445
|
*/
|
|
361
|
-
async function up$
|
|
446
|
+
async function up$111(db) {
|
|
362
447
|
await db.schema.alterTable("_dineway_collections").addColumn("search_config", "text").execute();
|
|
363
448
|
await db.schema.alterTable("_dineway_fields").addColumn("searchable", "integer", (col) => col.defaultTo(0)).execute();
|
|
364
449
|
}
|
|
365
|
-
async function down$
|
|
450
|
+
async function down$111(db) {
|
|
366
451
|
await db.schema.alterTable("_dineway_fields").dropColumn("searchable").execute();
|
|
367
452
|
await db.schema.alterTable("_dineway_collections").dropColumn("search_config").execute();
|
|
368
453
|
}
|
|
@@ -370,8 +455,8 @@ async function down$110(db) {
|
|
|
370
455
|
//#endregion
|
|
371
456
|
//#region src/database/migrations/013_scheduled_publishing.ts
|
|
372
457
|
var _013_scheduled_publishing_exports = /* @__PURE__ */ __exportAll({
|
|
373
|
-
down: () => down$
|
|
374
|
-
up: () => up$
|
|
458
|
+
down: () => down$110,
|
|
459
|
+
up: () => up$110
|
|
375
460
|
});
|
|
376
461
|
/**
|
|
377
462
|
* Migration: Add scheduled publishing support
|
|
@@ -380,7 +465,7 @@ var _013_scheduled_publishing_exports = /* @__PURE__ */ __exportAll({
|
|
|
380
465
|
* When scheduled_at is set and status is 'scheduled', the content
|
|
381
466
|
* will be auto-published when the scheduled time is reached.
|
|
382
467
|
*/
|
|
383
|
-
async function up$
|
|
468
|
+
async function up$110(db) {
|
|
384
469
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
385
470
|
for (const tableName of tableNames) {
|
|
386
471
|
const table = { name: tableName };
|
|
@@ -395,7 +480,7 @@ async function up$109(db) {
|
|
|
395
480
|
`.execute(db);
|
|
396
481
|
}
|
|
397
482
|
}
|
|
398
|
-
async function down$
|
|
483
|
+
async function down$110(db) {
|
|
399
484
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
400
485
|
for (const tableName of tableNames) {
|
|
401
486
|
const table = { name: tableName };
|
|
@@ -412,10 +497,10 @@ async function down$109(db) {
|
|
|
412
497
|
//#endregion
|
|
413
498
|
//#region src/database/migrations/014_draft_revisions.ts
|
|
414
499
|
var _014_draft_revisions_exports = /* @__PURE__ */ __exportAll({
|
|
415
|
-
down: () => down$
|
|
416
|
-
up: () => up$
|
|
500
|
+
down: () => down$109,
|
|
501
|
+
up: () => up$109
|
|
417
502
|
});
|
|
418
|
-
async function up$
|
|
503
|
+
async function up$109(db) {
|
|
419
504
|
const tables = await db.selectFrom("_dineway_collections").select("slug").execute();
|
|
420
505
|
for (const row of tables) {
|
|
421
506
|
const tableName = `ec_${row.slug}`;
|
|
@@ -437,7 +522,7 @@ async function up$108(db) {
|
|
|
437
522
|
`.execute(db);
|
|
438
523
|
}
|
|
439
524
|
}
|
|
440
|
-
async function down$
|
|
525
|
+
async function down$109(db) {
|
|
441
526
|
const tables = await db.selectFrom("_dineway_collections").select("slug").execute();
|
|
442
527
|
for (const row of tables) {
|
|
443
528
|
const tableName = `ec_${row.slug}`;
|
|
@@ -461,8 +546,8 @@ async function down$108(db) {
|
|
|
461
546
|
//#endregion
|
|
462
547
|
//#region src/database/migrations/015_indexes.ts
|
|
463
548
|
var _015_indexes_exports = /* @__PURE__ */ __exportAll({
|
|
464
|
-
down: () => down$
|
|
465
|
-
up: () => up$
|
|
549
|
+
down: () => down$108,
|
|
550
|
+
up: () => up$108
|
|
466
551
|
});
|
|
467
552
|
/**
|
|
468
553
|
* Add performance indexes for common query patterns.
|
|
@@ -475,7 +560,7 @@ var _015_indexes_exports = /* @__PURE__ */ __exportAll({
|
|
|
475
560
|
* 5. Retroactive author_id + updated_at on existing ec_* content tables
|
|
476
561
|
* (new tables get these from createContentTable() in registry.ts)
|
|
477
562
|
*/
|
|
478
|
-
async function up$
|
|
563
|
+
async function up$108(db) {
|
|
479
564
|
await db.schema.createIndex("idx_media_mime_type").on("media").column("mime_type").execute();
|
|
480
565
|
await db.schema.createIndex("idx_media_filename").on("media").column("filename").execute();
|
|
481
566
|
await db.schema.createIndex("idx_media_created_at").on("media").column("created_at").execute();
|
|
@@ -495,7 +580,7 @@ async function up$107(db) {
|
|
|
495
580
|
`.execute(db);
|
|
496
581
|
}
|
|
497
582
|
}
|
|
498
|
-
async function down$
|
|
583
|
+
async function down$108(db) {
|
|
499
584
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
500
585
|
for (const tableName of tableNames) {
|
|
501
586
|
const table = { name: tableName };
|
|
@@ -513,8 +598,8 @@ async function down$107(db) {
|
|
|
513
598
|
//#endregion
|
|
514
599
|
//#region src/database/migrations/016_api_tokens.ts
|
|
515
600
|
var _016_api_tokens_exports = /* @__PURE__ */ __exportAll({
|
|
516
|
-
down: () => down$
|
|
517
|
-
up: () => up$
|
|
601
|
+
down: () => down$107,
|
|
602
|
+
up: () => up$107
|
|
518
603
|
});
|
|
519
604
|
/**
|
|
520
605
|
* API token tables for programmatic access.
|
|
@@ -528,7 +613,7 @@ var _016_api_tokens_exports = /* @__PURE__ */ __exportAll({
|
|
|
528
613
|
* created only part of the schema before failing and never recorded the
|
|
529
614
|
* migration as applied.
|
|
530
615
|
*/
|
|
531
|
-
async function up$
|
|
616
|
+
async function up$107(db) {
|
|
532
617
|
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
618
|
await db.schema.createIndex("idx_api_tokens_token_hash").ifNotExists().on("_dineway_api_tokens").column("token_hash").execute();
|
|
534
619
|
await db.schema.createIndex("idx_api_tokens_user_id").ifNotExists().on("_dineway_api_tokens").column("user_id").execute();
|
|
@@ -537,7 +622,7 @@ async function up$106(db) {
|
|
|
537
622
|
await db.schema.createIndex("idx_oauth_tokens_expires").ifNotExists().on("_dineway_oauth_tokens").column("expires_at").execute();
|
|
538
623
|
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
624
|
}
|
|
540
|
-
async function down$
|
|
625
|
+
async function down$107(db) {
|
|
541
626
|
await db.schema.dropTable("_dineway_device_codes").ifExists().execute();
|
|
542
627
|
await db.schema.dropTable("_dineway_oauth_tokens").ifExists().execute();
|
|
543
628
|
await db.schema.dropTable("_dineway_api_tokens").ifExists().execute();
|
|
@@ -546,8 +631,8 @@ async function down$106(db) {
|
|
|
546
631
|
//#endregion
|
|
547
632
|
//#region src/database/migrations/017_authorization_codes.ts
|
|
548
633
|
var _017_authorization_codes_exports = /* @__PURE__ */ __exportAll({
|
|
549
|
-
down: () => down$
|
|
550
|
-
up: () => up$
|
|
634
|
+
down: () => down$106,
|
|
635
|
+
up: () => up$106
|
|
551
636
|
});
|
|
552
637
|
/**
|
|
553
638
|
* Authorization codes for OAuth 2.1 Authorization Code + PKCE flow.
|
|
@@ -557,20 +642,20 @@ var _017_authorization_codes_exports = /* @__PURE__ */ __exportAll({
|
|
|
557
642
|
*
|
|
558
643
|
* Also adds client_id tracking to oauth_tokens for per-client revocation.
|
|
559
644
|
*/
|
|
560
|
-
async function up$
|
|
645
|
+
async function up$106(db) {
|
|
561
646
|
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
647
|
await db.schema.createIndex("idx_auth_codes_expires").on("_dineway_authorization_codes").column("expires_at").execute();
|
|
563
648
|
await sql`ALTER TABLE _dineway_oauth_tokens ADD COLUMN client_id TEXT`.execute(db);
|
|
564
649
|
}
|
|
565
|
-
async function down$
|
|
650
|
+
async function down$106(db) {
|
|
566
651
|
await db.schema.dropTable("_dineway_authorization_codes").execute();
|
|
567
652
|
}
|
|
568
653
|
|
|
569
654
|
//#endregion
|
|
570
655
|
//#region src/database/migrations/018_seo.ts
|
|
571
656
|
var _018_seo_exports = /* @__PURE__ */ __exportAll({
|
|
572
|
-
down: () => down$
|
|
573
|
-
up: () => up$
|
|
657
|
+
down: () => down$105,
|
|
658
|
+
up: () => up$105
|
|
574
659
|
});
|
|
575
660
|
/**
|
|
576
661
|
* Migration: SEO support
|
|
@@ -583,7 +668,7 @@ var _018_seo_exports = /* @__PURE__ */ __exportAll({
|
|
|
583
668
|
* need it. The `has_seo` flag controls whether the admin shows SEO fields
|
|
584
669
|
* and whether the collection's content appears in sitemaps.
|
|
585
670
|
*/
|
|
586
|
-
async function up$
|
|
671
|
+
async function up$105(db) {
|
|
587
672
|
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
673
|
await sql`
|
|
589
674
|
CREATE INDEX idx_dineway_seo_collection
|
|
@@ -594,7 +679,7 @@ async function up$104(db) {
|
|
|
594
679
|
ADD COLUMN has_seo INTEGER NOT NULL DEFAULT 0
|
|
595
680
|
`.execute(db);
|
|
596
681
|
}
|
|
597
|
-
async function down$
|
|
682
|
+
async function down$105(db) {
|
|
598
683
|
await sql`DROP TABLE IF EXISTS _dineway_seo`.execute(db);
|
|
599
684
|
await sql`
|
|
600
685
|
ALTER TABLE _dineway_collections
|
|
@@ -605,8 +690,8 @@ async function down$104(db) {
|
|
|
605
690
|
//#endregion
|
|
606
691
|
//#region src/database/migrations/019_i18n.ts
|
|
607
692
|
var _019_i18n_exports = /* @__PURE__ */ __exportAll({
|
|
608
|
-
down: () => down$
|
|
609
|
-
up: () => up$
|
|
693
|
+
down: () => down$104,
|
|
694
|
+
up: () => up$104
|
|
610
695
|
});
|
|
611
696
|
/**
|
|
612
697
|
* Quote an identifier for use in raw SQL. Escapes embedded double-quotes
|
|
@@ -719,7 +804,7 @@ async function upPostgres(db) {
|
|
|
719
804
|
ADD COLUMN translatable INTEGER NOT NULL DEFAULT 1
|
|
720
805
|
`.execute(db);
|
|
721
806
|
}
|
|
722
|
-
async function up$
|
|
807
|
+
async function up$104(db) {
|
|
723
808
|
if (!isSqlite(db)) return upPostgres(db);
|
|
724
809
|
const orphanedTmps = await listTablesLike(db, "ec_%_i18n_tmp");
|
|
725
810
|
for (const tmpName of orphanedTmps) {
|
|
@@ -836,7 +921,7 @@ async function downPostgres(db) {
|
|
|
836
921
|
await sql`ALTER TABLE ${sql.ref(t)} DROP COLUMN translation_group`.execute(db);
|
|
837
922
|
}
|
|
838
923
|
}
|
|
839
|
-
async function down$
|
|
924
|
+
async function down$104(db) {
|
|
840
925
|
if (!isSqlite(db)) return downPostgres(db);
|
|
841
926
|
await sql`
|
|
842
927
|
ALTER TABLE _dineway_fields
|
|
@@ -943,8 +1028,8 @@ async function down$103(db) {
|
|
|
943
1028
|
//#endregion
|
|
944
1029
|
//#region src/database/migrations/020_collection_url_pattern.ts
|
|
945
1030
|
var _020_collection_url_pattern_exports = /* @__PURE__ */ __exportAll({
|
|
946
|
-
down: () => down$
|
|
947
|
-
up: () => up$
|
|
1031
|
+
down: () => down$103,
|
|
1032
|
+
up: () => up$103
|
|
948
1033
|
});
|
|
949
1034
|
/**
|
|
950
1035
|
* Migration: URL pattern for collections
|
|
@@ -953,13 +1038,13 @@ var _020_collection_url_pattern_exports = /* @__PURE__ */ __exportAll({
|
|
|
953
1038
|
* can declare its own URL structure (e.g. "/{slug}" for pages, "/blog/{slug}"
|
|
954
1039
|
* for posts). Used for menu URL resolution, sitemaps, and path-based lookups.
|
|
955
1040
|
*/
|
|
956
|
-
async function up$
|
|
1041
|
+
async function up$103(db) {
|
|
957
1042
|
await sql`
|
|
958
1043
|
ALTER TABLE _dineway_collections
|
|
959
1044
|
ADD COLUMN url_pattern TEXT
|
|
960
1045
|
`.execute(db);
|
|
961
1046
|
}
|
|
962
|
-
async function down$
|
|
1047
|
+
async function down$103(db) {
|
|
963
1048
|
await sql`
|
|
964
1049
|
ALTER TABLE _dineway_collections
|
|
965
1050
|
DROP COLUMN url_pattern
|
|
@@ -969,8 +1054,8 @@ async function down$102(db) {
|
|
|
969
1054
|
//#endregion
|
|
970
1055
|
//#region src/database/migrations/021_remove_section_categories.ts
|
|
971
1056
|
var _021_remove_section_categories_exports = /* @__PURE__ */ __exportAll({
|
|
972
|
-
down: () => down$
|
|
973
|
-
up: () => up$
|
|
1057
|
+
down: () => down$102,
|
|
1058
|
+
up: () => up$102
|
|
974
1059
|
});
|
|
975
1060
|
/**
|
|
976
1061
|
* Migration: Remove section categories
|
|
@@ -979,12 +1064,12 @@ var _021_remove_section_categories_exports = /* @__PURE__ */ __exportAll({
|
|
|
979
1064
|
* Rather than building the missing UI for a feature with very little need at this stage,
|
|
980
1065
|
* we're removing the feature entirely.
|
|
981
1066
|
*/
|
|
982
|
-
async function up$
|
|
1067
|
+
async function up$102(db) {
|
|
983
1068
|
await db.schema.dropIndex("idx_sections_category").ifExists().execute();
|
|
984
1069
|
await db.schema.alterTable("_dineway_sections").dropColumn("category_id").execute();
|
|
985
1070
|
await db.schema.dropTable("_dineway_section_categories").execute();
|
|
986
1071
|
}
|
|
987
|
-
async function down$
|
|
1072
|
+
async function down$102(db) {
|
|
988
1073
|
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
1074
|
await db.schema.alterTable("_dineway_sections").addColumn("category_id", "text", (col) => col.references("_dineway_section_categories.id").onDelete("set null")).execute();
|
|
990
1075
|
await db.schema.createIndex("idx_sections_category").on("_dineway_sections").columns(["category_id"]).execute();
|
|
@@ -993,8 +1078,8 @@ async function down$101(db) {
|
|
|
993
1078
|
//#endregion
|
|
994
1079
|
//#region src/database/migrations/022_marketplace_plugin_state.ts
|
|
995
1080
|
var _022_marketplace_plugin_state_exports = /* @__PURE__ */ __exportAll({
|
|
996
|
-
down: () => down$
|
|
997
|
-
up: () => up$
|
|
1081
|
+
down: () => down$101,
|
|
1082
|
+
up: () => up$101
|
|
998
1083
|
});
|
|
999
1084
|
/**
|
|
1000
1085
|
* Migration: Add marketplace fields to _plugin_state
|
|
@@ -1003,7 +1088,7 @@ var _022_marketplace_plugin_state_exports = /* @__PURE__ */ __exportAll({
|
|
|
1003
1088
|
* whether a plugin was installed from config or marketplace,
|
|
1004
1089
|
* and which marketplace version is installed.
|
|
1005
1090
|
*/
|
|
1006
|
-
async function up$
|
|
1091
|
+
async function up$101(db) {
|
|
1007
1092
|
await sql`
|
|
1008
1093
|
ALTER TABLE _plugin_state
|
|
1009
1094
|
ADD COLUMN source TEXT NOT NULL DEFAULT 'config'
|
|
@@ -1018,7 +1103,7 @@ async function up$100(db) {
|
|
|
1018
1103
|
WHERE source = 'marketplace'
|
|
1019
1104
|
`.execute(db);
|
|
1020
1105
|
}
|
|
1021
|
-
async function down$
|
|
1106
|
+
async function down$101(db) {
|
|
1022
1107
|
await sql`
|
|
1023
1108
|
DROP INDEX IF EXISTS idx_plugin_state_source
|
|
1024
1109
|
`.execute(db);
|
|
@@ -1035,8 +1120,8 @@ async function down$100(db) {
|
|
|
1035
1120
|
//#endregion
|
|
1036
1121
|
//#region src/database/migrations/023_plugin_metadata.ts
|
|
1037
1122
|
var _023_plugin_metadata_exports = /* @__PURE__ */ __exportAll({
|
|
1038
|
-
down: () => down$
|
|
1039
|
-
up: () => up$
|
|
1123
|
+
down: () => down$100,
|
|
1124
|
+
up: () => up$100
|
|
1040
1125
|
});
|
|
1041
1126
|
/**
|
|
1042
1127
|
* Migration: Add display metadata to _plugin_state
|
|
@@ -1045,7 +1130,7 @@ var _023_plugin_metadata_exports = /* @__PURE__ */ __exportAll({
|
|
|
1045
1130
|
* so the admin UI can show meaningful info without re-fetching
|
|
1046
1131
|
* from the marketplace on every page load.
|
|
1047
1132
|
*/
|
|
1048
|
-
async function up$
|
|
1133
|
+
async function up$100(db) {
|
|
1049
1134
|
await sql`
|
|
1050
1135
|
ALTER TABLE _plugin_state
|
|
1051
1136
|
ADD COLUMN display_name TEXT
|
|
@@ -1055,7 +1140,7 @@ async function up$99(db) {
|
|
|
1055
1140
|
ADD COLUMN description TEXT
|
|
1056
1141
|
`.execute(db);
|
|
1057
1142
|
}
|
|
1058
|
-
async function down$
|
|
1143
|
+
async function down$100(db) {
|
|
1059
1144
|
await sql`
|
|
1060
1145
|
ALTER TABLE _plugin_state
|
|
1061
1146
|
DROP COLUMN description
|
|
@@ -1069,8 +1154,8 @@ async function down$99(db) {
|
|
|
1069
1154
|
//#endregion
|
|
1070
1155
|
//#region src/database/migrations/024_media_placeholders.ts
|
|
1071
1156
|
var _024_media_placeholders_exports = /* @__PURE__ */ __exportAll({
|
|
1072
|
-
down: () => down$
|
|
1073
|
-
up: () => up$
|
|
1157
|
+
down: () => down$99,
|
|
1158
|
+
up: () => up$99
|
|
1074
1159
|
});
|
|
1075
1160
|
/**
|
|
1076
1161
|
* Migration: Add placeholder columns to media table
|
|
@@ -1078,7 +1163,7 @@ var _024_media_placeholders_exports = /* @__PURE__ */ __exportAll({
|
|
|
1078
1163
|
* Stores blurhash and dominant_color for LQIP (Low Quality Image Placeholder)
|
|
1079
1164
|
* support. Generated at upload time from image pixel data.
|
|
1080
1165
|
*/
|
|
1081
|
-
async function up$
|
|
1166
|
+
async function up$99(db) {
|
|
1082
1167
|
await sql`
|
|
1083
1168
|
ALTER TABLE media
|
|
1084
1169
|
ADD COLUMN blurhash TEXT
|
|
@@ -1088,7 +1173,7 @@ async function up$98(db) {
|
|
|
1088
1173
|
ADD COLUMN dominant_color TEXT
|
|
1089
1174
|
`.execute(db);
|
|
1090
1175
|
}
|
|
1091
|
-
async function down$
|
|
1176
|
+
async function down$99(db) {
|
|
1092
1177
|
await sql`
|
|
1093
1178
|
ALTER TABLE media
|
|
1094
1179
|
DROP COLUMN dominant_color
|
|
@@ -1102,8 +1187,8 @@ async function down$98(db) {
|
|
|
1102
1187
|
//#endregion
|
|
1103
1188
|
//#region src/database/migrations/025_oauth_clients.ts
|
|
1104
1189
|
var _025_oauth_clients_exports = /* @__PURE__ */ __exportAll({
|
|
1105
|
-
down: () => down$
|
|
1106
|
-
up: () => up$
|
|
1190
|
+
down: () => down$98,
|
|
1191
|
+
up: () => up$98
|
|
1107
1192
|
});
|
|
1108
1193
|
/**
|
|
1109
1194
|
* Migration: Create OAuth clients table
|
|
@@ -1114,18 +1199,18 @@ var _025_oauth_clients_exports = /* @__PURE__ */ __exportAll({
|
|
|
1114
1199
|
* Each client has a set of pre-registered redirect URIs (JSON array).
|
|
1115
1200
|
* The authorize endpoint rejects any redirect_uri not in the client's list.
|
|
1116
1201
|
*/
|
|
1117
|
-
async function up$
|
|
1202
|
+
async function up$98(db) {
|
|
1118
1203
|
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
1204
|
}
|
|
1120
|
-
async function down$
|
|
1205
|
+
async function down$98(db) {
|
|
1121
1206
|
await db.schema.dropTable("_dineway_oauth_clients").execute();
|
|
1122
1207
|
}
|
|
1123
1208
|
|
|
1124
1209
|
//#endregion
|
|
1125
1210
|
//#region src/database/migrations/026_cron_tasks.ts
|
|
1126
1211
|
var _026_cron_tasks_exports = /* @__PURE__ */ __exportAll({
|
|
1127
|
-
down: () => down$
|
|
1128
|
-
up: () => up$
|
|
1212
|
+
down: () => down$97,
|
|
1213
|
+
up: () => up$97
|
|
1129
1214
|
});
|
|
1130
1215
|
/**
|
|
1131
1216
|
* Migration: Create cron tasks table for plugin scheduled tasks.
|
|
@@ -1136,7 +1221,7 @@ var _026_cron_tasks_exports = /* @__PURE__ */ __exportAll({
|
|
|
1136
1221
|
* The `next_run_at` + `status` + `enabled` index drives the "find overdue
|
|
1137
1222
|
* tasks" query used by CronExecutor.tick().
|
|
1138
1223
|
*/
|
|
1139
|
-
async function up$
|
|
1224
|
+
async function up$97(db) {
|
|
1140
1225
|
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
1226
|
await db.schema.createIndex("idx_cron_tasks_due").on("_dineway_cron_tasks").columns([
|
|
1142
1227
|
"enabled",
|
|
@@ -1145,17 +1230,17 @@ async function up$96(db) {
|
|
|
1145
1230
|
]).execute();
|
|
1146
1231
|
await db.schema.createIndex("idx_cron_tasks_plugin").on("_dineway_cron_tasks").column("plugin_id").execute();
|
|
1147
1232
|
}
|
|
1148
|
-
async function down$
|
|
1233
|
+
async function down$97(db) {
|
|
1149
1234
|
await db.schema.dropTable("_dineway_cron_tasks").execute();
|
|
1150
1235
|
}
|
|
1151
1236
|
|
|
1152
1237
|
//#endregion
|
|
1153
1238
|
//#region src/database/migrations/027_comments.ts
|
|
1154
1239
|
var _027_comments_exports = /* @__PURE__ */ __exportAll({
|
|
1155
|
-
down: () => down$
|
|
1156
|
-
up: () => up$
|
|
1240
|
+
down: () => down$96,
|
|
1241
|
+
up: () => up$96
|
|
1157
1242
|
});
|
|
1158
|
-
async function up$
|
|
1243
|
+
async function up$96(db) {
|
|
1159
1244
|
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
1245
|
await db.schema.createIndex("idx_comments_content").on("_dineway_comments").columns([
|
|
1161
1246
|
"collection",
|
|
@@ -1171,30 +1256,30 @@ async function up$95(db) {
|
|
|
1171
1256
|
await db.schema.alterTable("_dineway_collections").addColumn("comments_closed_after_days", "integer", (col) => col.defaultTo(90)).execute();
|
|
1172
1257
|
await db.schema.alterTable("_dineway_collections").addColumn("comments_auto_approve_users", "integer", (col) => col.defaultTo(1)).execute();
|
|
1173
1258
|
}
|
|
1174
|
-
async function down$
|
|
1259
|
+
async function down$96(db) {
|
|
1175
1260
|
await db.schema.dropTable("_dineway_comments").execute();
|
|
1176
1261
|
}
|
|
1177
1262
|
|
|
1178
1263
|
//#endregion
|
|
1179
1264
|
//#region src/database/migrations/028_drop_author_url.ts
|
|
1180
1265
|
var _028_drop_author_url_exports = /* @__PURE__ */ __exportAll({
|
|
1181
|
-
down: () => down$
|
|
1182
|
-
up: () => up$
|
|
1266
|
+
down: () => down$95,
|
|
1267
|
+
up: () => up$95
|
|
1183
1268
|
});
|
|
1184
|
-
async function up$
|
|
1269
|
+
async function up$95(db) {
|
|
1185
1270
|
await sql`ALTER TABLE _dineway_comments DROP COLUMN author_url`.execute(db);
|
|
1186
1271
|
}
|
|
1187
|
-
async function down$
|
|
1272
|
+
async function down$95(db) {
|
|
1188
1273
|
await db.schema.alterTable("_dineway_comments").addColumn("author_url", "text").execute();
|
|
1189
1274
|
}
|
|
1190
1275
|
|
|
1191
1276
|
//#endregion
|
|
1192
1277
|
//#region src/database/migrations/029_redirects.ts
|
|
1193
1278
|
var _029_redirects_exports = /* @__PURE__ */ __exportAll({
|
|
1194
|
-
down: () => down$
|
|
1195
|
-
up: () => up$
|
|
1279
|
+
down: () => down$94,
|
|
1280
|
+
up: () => up$94
|
|
1196
1281
|
});
|
|
1197
|
-
async function up$
|
|
1282
|
+
async function up$94(db) {
|
|
1198
1283
|
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
1284
|
await db.schema.createIndex("idx_redirects_source").on("_dineway_redirects").column("source").execute();
|
|
1200
1285
|
await db.schema.createIndex("idx_redirects_enabled").on("_dineway_redirects").column("enabled").execute();
|
|
@@ -1203,7 +1288,7 @@ async function up$93(db) {
|
|
|
1203
1288
|
await db.schema.createIndex("idx_404_log_path").on("_dineway_404_log").column("path").execute();
|
|
1204
1289
|
await db.schema.createIndex("idx_404_log_created").on("_dineway_404_log").column("created_at").execute();
|
|
1205
1290
|
}
|
|
1206
|
-
async function down$
|
|
1291
|
+
async function down$94(db) {
|
|
1207
1292
|
await db.schema.dropTable("_dineway_404_log").execute();
|
|
1208
1293
|
await db.schema.dropTable("_dineway_redirects").execute();
|
|
1209
1294
|
}
|
|
@@ -1211,8 +1296,8 @@ async function down$93(db) {
|
|
|
1211
1296
|
//#endregion
|
|
1212
1297
|
//#region src/database/migrations/030_widen_scheduled_index.ts
|
|
1213
1298
|
var _030_widen_scheduled_index_exports = /* @__PURE__ */ __exportAll({
|
|
1214
|
-
down: () => down$
|
|
1215
|
-
up: () => up$
|
|
1299
|
+
down: () => down$93,
|
|
1300
|
+
up: () => up$93
|
|
1216
1301
|
});
|
|
1217
1302
|
/**
|
|
1218
1303
|
* Migration: Widen scheduled publishing index
|
|
@@ -1221,7 +1306,7 @@ var _030_widen_scheduled_index_exports = /* @__PURE__ */ __exportAll({
|
|
|
1221
1306
|
* Published posts can now have scheduled draft changes, so widen the
|
|
1222
1307
|
* index to cover all rows where scheduled_at IS NOT NULL.
|
|
1223
1308
|
*/
|
|
1224
|
-
async function up$
|
|
1309
|
+
async function up$93(db) {
|
|
1225
1310
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1226
1311
|
for (const tableName of tableNames) {
|
|
1227
1312
|
const table = { name: tableName };
|
|
@@ -1235,7 +1320,7 @@ async function up$92(db) {
|
|
|
1235
1320
|
`.execute(db);
|
|
1236
1321
|
}
|
|
1237
1322
|
}
|
|
1238
|
-
async function down$
|
|
1323
|
+
async function down$93(db) {
|
|
1239
1324
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1240
1325
|
for (const tableName of tableNames) {
|
|
1241
1326
|
const table = { name: tableName };
|
|
@@ -1253,10 +1338,10 @@ async function down$92(db) {
|
|
|
1253
1338
|
//#endregion
|
|
1254
1339
|
//#region src/database/migrations/031_bylines.ts
|
|
1255
1340
|
var _031_bylines_exports = /* @__PURE__ */ __exportAll({
|
|
1256
|
-
down: () => down$
|
|
1257
|
-
up: () => up$
|
|
1341
|
+
down: () => down$92,
|
|
1342
|
+
up: () => up$92
|
|
1258
1343
|
});
|
|
1259
|
-
async function up$
|
|
1344
|
+
async function up$92(db) {
|
|
1260
1345
|
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
1346
|
await sql`
|
|
1262
1347
|
CREATE UNIQUE INDEX ${sql.ref("idx_bylines_user_id_unique")}
|
|
@@ -1288,7 +1373,7 @@ async function up$91(db) {
|
|
|
1288
1373
|
`.execute(db);
|
|
1289
1374
|
}
|
|
1290
1375
|
}
|
|
1291
|
-
async function down$
|
|
1376
|
+
async function down$92(db) {
|
|
1292
1377
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1293
1378
|
for (const tableName of tableNames) {
|
|
1294
1379
|
await sql`
|
|
@@ -1306,8 +1391,8 @@ async function down$91(db) {
|
|
|
1306
1391
|
//#endregion
|
|
1307
1392
|
//#region src/database/migrations/032_rate_limits.ts
|
|
1308
1393
|
var _032_rate_limits_exports = /* @__PURE__ */ __exportAll({
|
|
1309
|
-
down: () => down$
|
|
1310
|
-
up: () => up$
|
|
1394
|
+
down: () => down$91,
|
|
1395
|
+
up: () => up$91
|
|
1311
1396
|
});
|
|
1312
1397
|
/**
|
|
1313
1398
|
* Migration: Rate limits table + device code polling tracking.
|
|
@@ -1318,12 +1403,12 @@ var _032_rate_limits_exports = /* @__PURE__ */ __exportAll({
|
|
|
1318
1403
|
* 2. Add last_polled_at column to _dineway_device_codes for
|
|
1319
1404
|
* RFC 8628 slow_down enforcement.
|
|
1320
1405
|
*/
|
|
1321
|
-
async function up$
|
|
1406
|
+
async function up$91(db) {
|
|
1322
1407
|
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
1408
|
await db.schema.createIndex("idx_rate_limits_window").on("_dineway_rate_limits").column("window").execute();
|
|
1324
1409
|
await db.schema.alterTable("_dineway_device_codes").addColumn("last_polled_at", "text").execute();
|
|
1325
1410
|
}
|
|
1326
|
-
async function down$
|
|
1411
|
+
async function down$91(db) {
|
|
1327
1412
|
await db.schema.dropTable("_dineway_rate_limits").execute();
|
|
1328
1413
|
await db.schema.alterTable("_dineway_device_codes").dropColumn("last_polled_at").execute();
|
|
1329
1414
|
}
|
|
@@ -1331,8 +1416,8 @@ async function down$90(db) {
|
|
|
1331
1416
|
//#endregion
|
|
1332
1417
|
//#region src/database/migrations/033_optimize_content_indexes.ts
|
|
1333
1418
|
var _033_optimize_content_indexes_exports = /* @__PURE__ */ __exportAll({
|
|
1334
|
-
down: () => down$
|
|
1335
|
-
up: () => up$
|
|
1419
|
+
down: () => down$90,
|
|
1420
|
+
up: () => up$90
|
|
1336
1421
|
});
|
|
1337
1422
|
/**
|
|
1338
1423
|
* Migration: Optimize content table indexes for SQLite-compatible performance
|
|
@@ -1345,7 +1430,7 @@ var _033_optimize_content_indexes_exports = /* @__PURE__ */ __exportAll({
|
|
|
1345
1430
|
*
|
|
1346
1431
|
* Impact: Reduces row reads by 90%+ for admin panel operations on SQLite-compatible adapters.
|
|
1347
1432
|
*/
|
|
1348
|
-
async function up$
|
|
1433
|
+
async function up$90(db) {
|
|
1349
1434
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1350
1435
|
for (const tableName of tableNames) {
|
|
1351
1436
|
const table = { name: tableName };
|
|
@@ -1387,7 +1472,7 @@ async function up$89(db) {
|
|
|
1387
1472
|
WHERE status = 'trash'
|
|
1388
1473
|
`.execute(db);
|
|
1389
1474
|
}
|
|
1390
|
-
async function down$
|
|
1475
|
+
async function down$90(db) {
|
|
1391
1476
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1392
1477
|
for (const tableName of tableNames) {
|
|
1393
1478
|
const table = { name: tableName };
|
|
@@ -1420,10 +1505,10 @@ async function down$89(db) {
|
|
|
1420
1505
|
//#endregion
|
|
1421
1506
|
//#region src/database/migrations/034_published_at_index.ts
|
|
1422
1507
|
var _034_published_at_index_exports = /* @__PURE__ */ __exportAll({
|
|
1423
|
-
down: () => down$
|
|
1424
|
-
up: () => up$
|
|
1508
|
+
down: () => down$89,
|
|
1509
|
+
up: () => up$89
|
|
1425
1510
|
});
|
|
1426
|
-
async function up$
|
|
1511
|
+
async function up$89(db) {
|
|
1427
1512
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1428
1513
|
for (const tableName of tableNames) {
|
|
1429
1514
|
const table = { name: tableName };
|
|
@@ -1433,7 +1518,7 @@ async function up$88(db) {
|
|
|
1433
1518
|
`.execute(db);
|
|
1434
1519
|
}
|
|
1435
1520
|
}
|
|
1436
|
-
async function down$
|
|
1521
|
+
async function down$89(db) {
|
|
1437
1522
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1438
1523
|
for (const tableName of tableNames) {
|
|
1439
1524
|
const table = { name: tableName };
|
|
@@ -1444,15 +1529,15 @@ async function down$88(db) {
|
|
|
1444
1529
|
//#endregion
|
|
1445
1530
|
//#region src/database/migrations/035_backfill_url_patterns.ts
|
|
1446
1531
|
var _035_backfill_url_patterns_exports = /* @__PURE__ */ __exportAll({
|
|
1447
|
-
down: () => down$
|
|
1448
|
-
up: () => up$
|
|
1532
|
+
down: () => down$88,
|
|
1533
|
+
up: () => up$88
|
|
1449
1534
|
});
|
|
1450
1535
|
/**
|
|
1451
1536
|
* Backfill default URL patterns for the built-in posts and pages collections.
|
|
1452
1537
|
*
|
|
1453
1538
|
* Existing rows keep custom patterns; only missing defaults are filled.
|
|
1454
1539
|
*/
|
|
1455
|
-
async function up$
|
|
1540
|
+
async function up$88(db) {
|
|
1456
1541
|
await sql`
|
|
1457
1542
|
UPDATE _dineway_collections
|
|
1458
1543
|
SET url_pattern = '/posts/{slug}'
|
|
@@ -1464,7 +1549,7 @@ async function up$87(db) {
|
|
|
1464
1549
|
WHERE slug = 'pages' AND url_pattern IS NULL
|
|
1465
1550
|
`.execute(db);
|
|
1466
1551
|
}
|
|
1467
|
-
async function down$
|
|
1552
|
+
async function down$88(db) {
|
|
1468
1553
|
await sql`
|
|
1469
1554
|
UPDATE _dineway_collections
|
|
1470
1555
|
SET url_pattern = NULL
|
|
@@ -1480,8 +1565,8 @@ async function down$87(db) {
|
|
|
1480
1565
|
//#endregion
|
|
1481
1566
|
//#region src/database/migrations/036_activity_log.ts
|
|
1482
1567
|
var _036_activity_log_exports = /* @__PURE__ */ __exportAll({
|
|
1483
|
-
down: () => down$
|
|
1484
|
-
up: () => up$
|
|
1568
|
+
down: () => down$87,
|
|
1569
|
+
up: () => up$87
|
|
1485
1570
|
});
|
|
1486
1571
|
/**
|
|
1487
1572
|
* Site Context Engine activity foundation.
|
|
@@ -1490,7 +1575,7 @@ var _036_activity_log_exports = /* @__PURE__ */ __exportAll({
|
|
|
1490
1575
|
* not a request log. Actor IDs intentionally have no foreign key because the
|
|
1491
1576
|
* actor source can be users, API tokens, or a stable system actor.
|
|
1492
1577
|
*/
|
|
1493
|
-
async function up$
|
|
1578
|
+
async function up$87(db) {
|
|
1494
1579
|
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
1580
|
await db.schema.createIndex("idx_dineway_activity_actor").on("_dineway_activity_log").columns([
|
|
1496
1581
|
"actor_type",
|
|
@@ -1517,15 +1602,15 @@ async function up$86(db) {
|
|
|
1517
1602
|
await db.schema.createIndex("idx_dineway_activity_result_status").on("_dineway_activity_log").columns(["result_status", "created_at"]).execute();
|
|
1518
1603
|
await db.schema.createIndex("idx_dineway_activity_created_at").on("_dineway_activity_log").column("created_at").execute();
|
|
1519
1604
|
}
|
|
1520
|
-
async function down$
|
|
1605
|
+
async function down$87(db) {
|
|
1521
1606
|
await db.schema.dropTable("_dineway_activity_log").execute();
|
|
1522
1607
|
}
|
|
1523
1608
|
|
|
1524
1609
|
//#endregion
|
|
1525
1610
|
//#region src/database/migrations/037_context_entries.ts
|
|
1526
1611
|
var _037_context_entries_exports = /* @__PURE__ */ __exportAll({
|
|
1527
|
-
down: () => down$
|
|
1528
|
-
up: () => up$
|
|
1612
|
+
down: () => down$86,
|
|
1613
|
+
up: () => up$86
|
|
1529
1614
|
});
|
|
1530
1615
|
const CONTEXT_TYPE_SQL = [
|
|
1531
1616
|
"brand_voice",
|
|
@@ -1550,7 +1635,7 @@ const CONTEXT_TYPE_SQL = [
|
|
|
1550
1635
|
* marking old entries non-current and linking replacements through
|
|
1551
1636
|
* `supersedes_id`.
|
|
1552
1637
|
*/
|
|
1553
|
-
async function up$
|
|
1638
|
+
async function up$86(db) {
|
|
1554
1639
|
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
1640
|
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
1641
|
await db.schema.createIndex("idx_dineway_context_scope_current").on("_dineway_context_entries").columns([
|
|
@@ -1575,7 +1660,7 @@ async function up$85(db) {
|
|
|
1575
1660
|
await db.schema.createIndex("idx_dineway_context_created_at").on("_dineway_context_entries").column("created_at").execute();
|
|
1576
1661
|
await db.schema.createIndex("idx_dineway_context_tags_tag").on("_dineway_context_tags").columns(["tag", "context_entry_id"]).execute();
|
|
1577
1662
|
}
|
|
1578
|
-
async function down$
|
|
1663
|
+
async function down$86(db) {
|
|
1579
1664
|
await db.schema.dropTable("_dineway_context_tags").execute();
|
|
1580
1665
|
await db.schema.dropTable("_dineway_context_entries").execute();
|
|
1581
1666
|
}
|
|
@@ -1583,8 +1668,8 @@ async function down$85(db) {
|
|
|
1583
1668
|
//#endregion
|
|
1584
1669
|
//#region src/database/migrations/038_review_requests.ts
|
|
1585
1670
|
var _038_review_requests_exports = /* @__PURE__ */ __exportAll({
|
|
1586
|
-
down: () => down$
|
|
1587
|
-
up: () => up$
|
|
1671
|
+
down: () => down$85,
|
|
1672
|
+
up: () => up$85
|
|
1588
1673
|
});
|
|
1589
1674
|
/**
|
|
1590
1675
|
* Lightweight content review requests for Phase 5a.
|
|
@@ -1592,7 +1677,7 @@ var _038_review_requests_exports = /* @__PURE__ */ __exportAll({
|
|
|
1592
1677
|
* Review requests bind human approval to immutable content revision/action
|
|
1593
1678
|
* identifiers so an approval cannot be reused after the draft or action changes.
|
|
1594
1679
|
*/
|
|
1595
|
-
async function up$
|
|
1680
|
+
async function up$85(db) {
|
|
1596
1681
|
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
1682
|
await db.schema.createIndex("idx_dineway_review_status_created").on("_dineway_review_requests").columns(["status", "created_at"]).execute();
|
|
1598
1683
|
await db.schema.createIndex("idx_dineway_review_target").on("_dineway_review_requests").columns([
|
|
@@ -1613,15 +1698,15 @@ async function up$84(db) {
|
|
|
1613
1698
|
]).execute();
|
|
1614
1699
|
await db.schema.createIndex("idx_dineway_review_resolved_at").on("_dineway_review_requests").column("resolved_at").execute();
|
|
1615
1700
|
}
|
|
1616
|
-
async function down$
|
|
1701
|
+
async function down$85(db) {
|
|
1617
1702
|
await db.schema.dropTable("_dineway_review_requests").execute();
|
|
1618
1703
|
}
|
|
1619
1704
|
|
|
1620
1705
|
//#endregion
|
|
1621
1706
|
//#region src/database/migrations/039_entity_aliases.ts
|
|
1622
1707
|
var _039_entity_aliases_exports = /* @__PURE__ */ __exportAll({
|
|
1623
|
-
down: () => down$
|
|
1624
|
-
up: () => up$
|
|
1708
|
+
down: () => down$84,
|
|
1709
|
+
up: () => up$84
|
|
1625
1710
|
});
|
|
1626
1711
|
const ENTITY_ALIAS_TYPES = [
|
|
1627
1712
|
"content",
|
|
@@ -1636,7 +1721,7 @@ const ENTITY_ALIAS_TYPES = [
|
|
|
1636
1721
|
* This replaces CRMy's PostgreSQL-specific alias arrays with a normalized
|
|
1637
1722
|
* mapping table that works across SQLite/libSQL and PostgreSQL.
|
|
1638
1723
|
*/
|
|
1639
|
-
async function up$
|
|
1724
|
+
async function up$84(db) {
|
|
1640
1725
|
const entityTypesSql = sql.join(ENTITY_ALIAS_TYPES.map((value) => sql.lit(value)), sql`, `);
|
|
1641
1726
|
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
1727
|
await db.schema.createIndex("idx_dineway_entity_alias_lookup").on("_dineway_entity_aliases").columns(["entity_type", "normalized_alias"]).execute();
|
|
@@ -1653,15 +1738,15 @@ async function up$83(db) {
|
|
|
1653
1738
|
"normalized_alias"
|
|
1654
1739
|
]).unique().execute();
|
|
1655
1740
|
}
|
|
1656
|
-
async function down$
|
|
1741
|
+
async function down$84(db) {
|
|
1657
1742
|
await db.schema.dropTable("_dineway_entity_aliases").execute();
|
|
1658
1743
|
}
|
|
1659
1744
|
|
|
1660
1745
|
//#endregion
|
|
1661
1746
|
//#region src/database/migrations/040_handoff_snapshots.ts
|
|
1662
1747
|
var _040_handoff_snapshots_exports = /* @__PURE__ */ __exportAll({
|
|
1663
|
-
down: () => down$
|
|
1664
|
-
up: () => up$
|
|
1748
|
+
down: () => down$83,
|
|
1749
|
+
up: () => up$83
|
|
1665
1750
|
});
|
|
1666
1751
|
const ACTOR_TYPES$4 = [
|
|
1667
1752
|
"user",
|
|
@@ -1674,7 +1759,7 @@ const HANDOFF_KINDS = [
|
|
|
1674
1759
|
"assignment"
|
|
1675
1760
|
];
|
|
1676
1761
|
const REFERENCE_TYPES = ["review_request", "assignment"];
|
|
1677
|
-
async function up$
|
|
1762
|
+
async function up$83(db) {
|
|
1678
1763
|
const actorTypesSql = sql.join(ACTOR_TYPES$4.map((value) => sql.lit(value)), sql`, `);
|
|
1679
1764
|
const handoffKindsSql = sql.join(HANDOFF_KINDS.map((value) => sql.lit(value)), sql`, `);
|
|
1680
1765
|
const referenceTypesSql = sql.join(REFERENCE_TYPES.map((value) => sql.lit(value)), sql`, `);
|
|
@@ -1688,15 +1773,15 @@ async function up$82(db) {
|
|
|
1688
1773
|
await db.schema.createIndex("idx_dineway_handoff_kind_created").on("_dineway_handoff_snapshots").columns(["handoff_kind", "created_at"]).execute();
|
|
1689
1774
|
await db.schema.createIndex("idx_dineway_handoff_reference").on("_dineway_handoff_snapshots").columns(["reference_type", "reference_id"]).execute();
|
|
1690
1775
|
}
|
|
1691
|
-
async function down$
|
|
1776
|
+
async function down$83(db) {
|
|
1692
1777
|
await db.schema.dropTable("_dineway_handoff_snapshots").execute();
|
|
1693
1778
|
}
|
|
1694
1779
|
|
|
1695
1780
|
//#endregion
|
|
1696
1781
|
//#region src/database/migrations/041_assignments.ts
|
|
1697
1782
|
var _041_assignments_exports = /* @__PURE__ */ __exportAll({
|
|
1698
|
-
down: () => down$
|
|
1699
|
-
up: () => up$
|
|
1783
|
+
down: () => down$82,
|
|
1784
|
+
up: () => up$82
|
|
1700
1785
|
});
|
|
1701
1786
|
const ACTOR_TYPES$3 = [
|
|
1702
1787
|
"user",
|
|
@@ -1718,7 +1803,7 @@ const ASSIGNMENT_PRIORITIES = [
|
|
|
1718
1803
|
"high",
|
|
1719
1804
|
"urgent"
|
|
1720
1805
|
];
|
|
1721
|
-
async function up$
|
|
1806
|
+
async function up$82(db) {
|
|
1722
1807
|
const actorTypesSql = sql.join(ACTOR_TYPES$3.map((value) => sql.lit(value)), sql`, `);
|
|
1723
1808
|
const statusesSql = sql.join(ASSIGNMENT_STATUSES.map((value) => sql.lit(value)), sql`, `);
|
|
1724
1809
|
const prioritiesSql = sql.join(ASSIGNMENT_PRIORITIES.map((value) => sql.lit(value)), sql`, `);
|
|
@@ -1750,15 +1835,15 @@ async function up$81(db) {
|
|
|
1750
1835
|
await db.schema.createIndex("idx_dineway_assignment_due_at").on("_dineway_assignments").column("due_at").execute();
|
|
1751
1836
|
await db.schema.createIndex("idx_dineway_assignment_handoff").on("_dineway_assignments").column("related_handoff_snapshot_id").execute();
|
|
1752
1837
|
}
|
|
1753
|
-
async function down$
|
|
1838
|
+
async function down$82(db) {
|
|
1754
1839
|
await db.schema.dropTable("_dineway_assignments").execute();
|
|
1755
1840
|
}
|
|
1756
1841
|
|
|
1757
1842
|
//#endregion
|
|
1758
1843
|
//#region src/database/migrations/042_hitl_requests.ts
|
|
1759
1844
|
var _042_hitl_requests_exports = /* @__PURE__ */ __exportAll({
|
|
1760
|
-
down: () => down$
|
|
1761
|
-
up: () => up$
|
|
1845
|
+
down: () => down$81,
|
|
1846
|
+
up: () => up$81
|
|
1762
1847
|
});
|
|
1763
1848
|
const ACTOR_TYPES$2 = [
|
|
1764
1849
|
"user",
|
|
@@ -1776,7 +1861,7 @@ const HITL_PRIORITIES = [
|
|
|
1776
1861
|
"high",
|
|
1777
1862
|
"urgent"
|
|
1778
1863
|
];
|
|
1779
|
-
async function up$
|
|
1864
|
+
async function up$81(db) {
|
|
1780
1865
|
const actorTypesSql = sql.join(ACTOR_TYPES$2.map((value) => sql.lit(value)), sql`, `);
|
|
1781
1866
|
const statusesSql = sql.join(HITL_STATUSES.map((value) => sql.lit(value)), sql`, `);
|
|
1782
1867
|
const prioritiesSql = sql.join(HITL_PRIORITIES.map((value) => sql.lit(value)), sql`, `);
|
|
@@ -1811,7 +1896,7 @@ async function up$80(db) {
|
|
|
1811
1896
|
await db.schema.createIndex("idx_dineway_hitl_sla_due_at").on("_dineway_hitl_requests").column("sla_due_at").execute();
|
|
1812
1897
|
await db.schema.createIndex("idx_dineway_assignment_hitl").on("_dineway_assignments").column("related_hitl_request_id").execute();
|
|
1813
1898
|
}
|
|
1814
|
-
async function down$
|
|
1899
|
+
async function down$81(db) {
|
|
1815
1900
|
await db.schema.dropIndex("idx_dineway_assignment_hitl").execute();
|
|
1816
1901
|
await db.schema.alterTable("_dineway_assignments").dropColumn("related_hitl_request_id").execute();
|
|
1817
1902
|
await db.schema.dropTable("_dineway_hitl_requests").execute();
|
|
@@ -1820,8 +1905,8 @@ async function down$80(db) {
|
|
|
1820
1905
|
//#endregion
|
|
1821
1906
|
//#region src/database/migrations/043_bounded_404_log.ts
|
|
1822
1907
|
var _043_bounded_404_log_exports = /* @__PURE__ */ __exportAll({
|
|
1823
|
-
down: () => down$
|
|
1824
|
-
up: () => up$
|
|
1908
|
+
down: () => down$80,
|
|
1909
|
+
up: () => up$80
|
|
1825
1910
|
});
|
|
1826
1911
|
/**
|
|
1827
1912
|
* Migration: Bounded 404 logging
|
|
@@ -1830,7 +1915,7 @@ var _043_bounded_404_log_exports = /* @__PURE__ */ __exportAll({
|
|
|
1830
1915
|
* Previously every 404 inserted a new row, so a requester could grow the
|
|
1831
1916
|
* table without bound by hitting unique URLs.
|
|
1832
1917
|
*/
|
|
1833
|
-
async function up$
|
|
1918
|
+
async function up$80(db) {
|
|
1834
1919
|
await db.schema.alterTable("_dineway_404_log").addColumn("hits", "integer", (col) => col.notNull().defaultTo(1)).execute();
|
|
1835
1920
|
await db.schema.alterTable("_dineway_404_log").addColumn("last_seen_at", "text").execute();
|
|
1836
1921
|
await sql`
|
|
@@ -1876,7 +1961,7 @@ async function up$79(db) {
|
|
|
1876
1961
|
await db.schema.dropIndex("idx_404_log_path").execute();
|
|
1877
1962
|
await db.schema.createIndex("idx_404_log_last_seen").on("_dineway_404_log").column("last_seen_at").execute();
|
|
1878
1963
|
}
|
|
1879
|
-
async function down$
|
|
1964
|
+
async function down$80(db) {
|
|
1880
1965
|
await db.schema.dropIndex("idx_404_log_last_seen").execute();
|
|
1881
1966
|
await db.schema.dropIndex("idx_404_log_path_unique").execute();
|
|
1882
1967
|
await db.schema.createIndex("idx_404_log_path").on("_dineway_404_log").column("path").execute();
|
|
@@ -1887,21 +1972,21 @@ async function down$79(db) {
|
|
|
1887
1972
|
//#endregion
|
|
1888
1973
|
//#region src/database/migrations/044_credential_algorithm.ts
|
|
1889
1974
|
var _044_credential_algorithm_exports = /* @__PURE__ */ __exportAll({
|
|
1890
|
-
down: () => down$
|
|
1891
|
-
up: () => up$
|
|
1975
|
+
down: () => down$79,
|
|
1976
|
+
up: () => up$79
|
|
1892
1977
|
});
|
|
1893
|
-
async function up$
|
|
1978
|
+
async function up$79(db) {
|
|
1894
1979
|
if (!await columnExists(db, "credentials", "algorithm")) await db.schema.alterTable("credentials").addColumn("algorithm", "integer", (col) => col.notNull().defaultTo(-7)).execute();
|
|
1895
1980
|
}
|
|
1896
|
-
async function down$
|
|
1981
|
+
async function down$79(db) {
|
|
1897
1982
|
if (await columnExists(db, "credentials", "algorithm")) await db.schema.alterTable("credentials").dropColumn("algorithm").execute();
|
|
1898
1983
|
}
|
|
1899
1984
|
|
|
1900
1985
|
//#endregion
|
|
1901
1986
|
//#region src/database/migrations/045_i18n_menus_and_taxonomies.ts
|
|
1902
1987
|
var _045_i18n_menus_and_taxonomies_exports = /* @__PURE__ */ __exportAll({
|
|
1903
|
-
down: () => down$
|
|
1904
|
-
up: () => up$
|
|
1988
|
+
down: () => down$78,
|
|
1989
|
+
up: () => up$78
|
|
1905
1990
|
});
|
|
1906
1991
|
/**
|
|
1907
1992
|
* i18n for menus + taxonomies. Adds `locale` + `translation_group` to system
|
|
@@ -1912,7 +1997,7 @@ var _045_i18n_menus_and_taxonomies_exports = /* @__PURE__ */ __exportAll({
|
|
|
1912
1997
|
function getDefaultLocale$1() {
|
|
1913
1998
|
return getI18nConfig()?.defaultLocale ?? "en";
|
|
1914
1999
|
}
|
|
1915
|
-
async function up$
|
|
2000
|
+
async function up$78(db) {
|
|
1916
2001
|
const defaultLocale = getDefaultLocale$1();
|
|
1917
2002
|
if (isSqlite(db)) {
|
|
1918
2003
|
await sql.raw(`PRAGMA foreign_keys = OFF`).execute(db);
|
|
@@ -2103,7 +2188,7 @@ async function assertSingleLocale$1(db, defaultLocale) {
|
|
|
2103
2188
|
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
2189
|
}
|
|
2105
2190
|
}
|
|
2106
|
-
async function down$
|
|
2191
|
+
async function down$78(db) {
|
|
2107
2192
|
const defaultLocale = getDefaultLocale$1();
|
|
2108
2193
|
await assertSingleLocale$1(db, defaultLocale);
|
|
2109
2194
|
const widenedTables = [
|
|
@@ -2197,21 +2282,21 @@ async function rebuildTaxonomyDefsDown(db) {
|
|
|
2197
2282
|
//#endregion
|
|
2198
2283
|
//#region src/database/migrations/046_astro_sessions.ts
|
|
2199
2284
|
var _046_astro_sessions_exports = /* @__PURE__ */ __exportAll({
|
|
2200
|
-
down: () => down$
|
|
2201
|
-
up: () => up$
|
|
2285
|
+
down: () => down$77,
|
|
2286
|
+
up: () => up$77
|
|
2202
2287
|
});
|
|
2203
|
-
async function up$
|
|
2288
|
+
async function up$77(db) {
|
|
2204
2289
|
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
2290
|
}
|
|
2206
|
-
async function down$
|
|
2291
|
+
async function down$77(db) {
|
|
2207
2292
|
await db.schema.dropTable("_dineway_sessions").ifExists().execute();
|
|
2208
2293
|
}
|
|
2209
2294
|
|
|
2210
2295
|
//#endregion
|
|
2211
2296
|
//#region src/database/migrations/047_content_locale_list_index.ts
|
|
2212
2297
|
var _047_content_locale_list_index_exports = /* @__PURE__ */ __exportAll({
|
|
2213
|
-
down: () => down$
|
|
2214
|
-
up: () => up$
|
|
2298
|
+
down: () => down$76,
|
|
2299
|
+
up: () => up$76
|
|
2215
2300
|
});
|
|
2216
2301
|
/**
|
|
2217
2302
|
* Add locale-aware composite indexes for content list queries.
|
|
@@ -2221,7 +2306,7 @@ var _047_content_locale_list_index_exports = /* @__PURE__ */ __exportAll({
|
|
|
2221
2306
|
* path but omit locale, so locale-filtered lists cannot be served by one index
|
|
2222
2307
|
* on large tables.
|
|
2223
2308
|
*/
|
|
2224
|
-
async function up$
|
|
2309
|
+
async function up$76(db) {
|
|
2225
2310
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
2226
2311
|
for (const tableName of tableNames) {
|
|
2227
2312
|
await sql`
|
|
@@ -2234,7 +2319,7 @@ async function up$75(db) {
|
|
|
2234
2319
|
`.execute(db);
|
|
2235
2320
|
}
|
|
2236
2321
|
}
|
|
2237
|
-
async function down$
|
|
2322
|
+
async function down$76(db) {
|
|
2238
2323
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
2239
2324
|
for (const tableName of tableNames) {
|
|
2240
2325
|
await sql`DROP INDEX IF EXISTS ${sql.ref(contentLocaleUpdatedIndexName(tableName))}`.execute(db);
|
|
@@ -2245,8 +2330,8 @@ async function down$75(db) {
|
|
|
2245
2330
|
//#endregion
|
|
2246
2331
|
//#region src/database/migrations/048_byline_i18n.ts
|
|
2247
2332
|
var _048_byline_i18n_exports = /* @__PURE__ */ __exportAll({
|
|
2248
|
-
down: () => down$
|
|
2249
|
-
up: () => up$
|
|
2333
|
+
down: () => down$75,
|
|
2334
|
+
up: () => up$75
|
|
2250
2335
|
});
|
|
2251
2336
|
/**
|
|
2252
2337
|
* Adds row-per-locale bylines.
|
|
@@ -2259,7 +2344,7 @@ var _048_byline_i18n_exports = /* @__PURE__ */ __exportAll({
|
|
|
2259
2344
|
function getDefaultLocale() {
|
|
2260
2345
|
return getI18nConfig()?.defaultLocale ?? "en";
|
|
2261
2346
|
}
|
|
2262
|
-
async function up$
|
|
2347
|
+
async function up$75(db) {
|
|
2263
2348
|
const defaultLocale = getDefaultLocale();
|
|
2264
2349
|
if (isSqlite(db)) {
|
|
2265
2350
|
await rebuildContentBylines(db);
|
|
@@ -2418,7 +2503,7 @@ async function assertSingleLocale(db, defaultLocale) {
|
|
|
2418
2503
|
const count = Number(result.rows[0]?.count ?? 0);
|
|
2419
2504
|
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
2505
|
}
|
|
2421
|
-
async function down$
|
|
2506
|
+
async function down$75(db) {
|
|
2422
2507
|
const defaultLocale = getDefaultLocale();
|
|
2423
2508
|
await assertSingleLocale(db, defaultLocale);
|
|
2424
2509
|
await assertContentBylinesResolve(db, defaultLocale);
|
|
@@ -2540,10 +2625,10 @@ async function restoreContentBylinesFk(db) {
|
|
|
2540
2625
|
//#endregion
|
|
2541
2626
|
//#region src/database/migrations/049_byline_fields.ts
|
|
2542
2627
|
var _049_byline_fields_exports = /* @__PURE__ */ __exportAll({
|
|
2543
|
-
down: () => down$
|
|
2544
|
-
up: () => up$
|
|
2628
|
+
down: () => down$74,
|
|
2629
|
+
up: () => up$74
|
|
2545
2630
|
});
|
|
2546
|
-
async function up$
|
|
2631
|
+
async function up$74(db) {
|
|
2547
2632
|
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
2633
|
await db.schema.createIndex("idx__dineway_byline_fields_sort_order").ifNotExists().on("_dineway_byline_fields").column("sort_order").execute();
|
|
2549
2634
|
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 +2642,7 @@ async function up$73(db) {
|
|
|
2557
2642
|
ON CONFLICT (name) DO NOTHING
|
|
2558
2643
|
`.execute(db);
|
|
2559
2644
|
}
|
|
2560
|
-
async function down$
|
|
2645
|
+
async function down$74(db) {
|
|
2561
2646
|
await db.schema.dropTable("_dineway_byline_field_group_values").ifExists().execute();
|
|
2562
2647
|
await db.schema.dropTable("_dineway_byline_field_values").ifExists().execute();
|
|
2563
2648
|
await db.schema.dropTable("_dineway_byline_fields").ifExists().execute();
|
|
@@ -2567,8 +2652,8 @@ async function down$73(db) {
|
|
|
2567
2652
|
//#endregion
|
|
2568
2653
|
//#region src/database/migrations/050_content_references.ts
|
|
2569
2654
|
var _050_content_references_exports = /* @__PURE__ */ __exportAll({
|
|
2570
|
-
down: () => down$
|
|
2571
|
-
up: () => up$
|
|
2655
|
+
down: () => down$73,
|
|
2656
|
+
up: () => up$73
|
|
2572
2657
|
});
|
|
2573
2658
|
/**
|
|
2574
2659
|
* Content references.
|
|
@@ -2577,7 +2662,7 @@ var _050_content_references_exports = /* @__PURE__ */ __exportAll({
|
|
|
2577
2662
|
* with one localized row per locale. `_dineway_content_references` stores
|
|
2578
2663
|
* parent -> child edges keyed by translation groups so edges are locale-agnostic.
|
|
2579
2664
|
*/
|
|
2580
|
-
async function up$
|
|
2665
|
+
async function up$73(db) {
|
|
2581
2666
|
const defaultLocale = getI18nConfig()?.defaultLocale ?? "en";
|
|
2582
2667
|
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
2668
|
await db.schema.createIndex("idx__dineway_relations_locale").ifNotExists().on("_dineway_relations").column("locale").execute();
|
|
@@ -2598,7 +2683,7 @@ async function up$72(db) {
|
|
|
2598
2683
|
await db.schema.createIndex("idx__dineway_content_references_child").ifNotExists().on("_dineway_content_references").columns(["child_group", "relation_group"]).execute();
|
|
2599
2684
|
await db.schema.createIndex("idx__dineway_content_references_relation").ifNotExists().on("_dineway_content_references").column("relation_group").execute();
|
|
2600
2685
|
}
|
|
2601
|
-
async function down$
|
|
2686
|
+
async function down$73(db) {
|
|
2602
2687
|
await db.schema.dropTable("_dineway_content_references").ifExists().execute();
|
|
2603
2688
|
await db.schema.dropTable("_dineway_relations").ifExists().execute();
|
|
2604
2689
|
}
|
|
@@ -2606,8 +2691,8 @@ async function down$72(db) {
|
|
|
2606
2691
|
//#endregion
|
|
2607
2692
|
//#region src/database/migrations/051_dineway_web_plugin.ts
|
|
2608
2693
|
var _051_dineway_web_plugin_exports = /* @__PURE__ */ __exportAll({
|
|
2609
|
-
down: () => down$
|
|
2610
|
-
up: () => up$
|
|
2694
|
+
down: () => down$72,
|
|
2695
|
+
up: () => up$72
|
|
2611
2696
|
});
|
|
2612
2697
|
const SESSION_STATUSES = [
|
|
2613
2698
|
"active",
|
|
@@ -2642,7 +2727,7 @@ const HANDOFF_AUDIT_EVENTS = [
|
|
|
2642
2727
|
function enumValues(values) {
|
|
2643
2728
|
return sql.join(values.map((value) => sql.lit(value)), sql`, `);
|
|
2644
2729
|
}
|
|
2645
|
-
async function up$
|
|
2730
|
+
async function up$72(db) {
|
|
2646
2731
|
const sessionStatuses = enumValues(SESSION_STATUSES);
|
|
2647
2732
|
const onboardingStatuses = enumValues(ONBOARDING_STATUSES);
|
|
2648
2733
|
const checkoutStatuses = enumValues(CHECKOUT_STATUSES);
|
|
@@ -2685,7 +2770,7 @@ async function up$71(db) {
|
|
|
2685
2770
|
await db.schema.createIndex("idx_dineway_web_handoff_audit_handoff").ifNotExists().on("_dineway_dineway_web_handoff_audit").column("handoff_id").execute();
|
|
2686
2771
|
await db.schema.createIndex("idx_dineway_web_handoff_audit_event").ifNotExists().on("_dineway_dineway_web_handoff_audit").column("event").execute();
|
|
2687
2772
|
}
|
|
2688
|
-
async function down$
|
|
2773
|
+
async function down$72(db) {
|
|
2689
2774
|
await db.schema.dropTable("_dineway_dineway_web_handoff_audit").ifExists().execute();
|
|
2690
2775
|
await db.schema.dropTable("_dineway_dineway_web_handoffs").ifExists().execute();
|
|
2691
2776
|
await db.schema.dropTable("_dineway_dineway_web_sites_projections").ifExists().execute();
|
|
@@ -2700,19 +2785,19 @@ async function down$71(db) {
|
|
|
2700
2785
|
//#endregion
|
|
2701
2786
|
//#region src/database/migrations/052_taxonomies_name_locale_index.ts
|
|
2702
2787
|
var _052_taxonomies_name_locale_index_exports = /* @__PURE__ */ __exportAll({
|
|
2703
|
-
down: () => down$
|
|
2704
|
-
up: () => up$
|
|
2788
|
+
down: () => down$71,
|
|
2789
|
+
up: () => up$71
|
|
2705
2790
|
});
|
|
2706
2791
|
/**
|
|
2707
2792
|
* Add a composite taxonomy lookup index for queries that filter by name and locale.
|
|
2708
2793
|
* The composite's leftmost prefix covers name-only lookups, so it replaces the
|
|
2709
2794
|
* older single-column name index while preserving the locale-only index.
|
|
2710
2795
|
*/
|
|
2711
|
-
async function up$
|
|
2796
|
+
async function up$71(db) {
|
|
2712
2797
|
await db.schema.createIndex("idx_taxonomies_name_locale").ifNotExists().on("taxonomies").columns(["name", "locale"]).execute();
|
|
2713
2798
|
await db.schema.dropIndex("idx_taxonomies_name").ifExists().execute();
|
|
2714
2799
|
}
|
|
2715
|
-
async function down$
|
|
2800
|
+
async function down$71(db) {
|
|
2716
2801
|
await db.schema.createIndex("idx_taxonomies_name").ifNotExists().on("taxonomies").column("name").execute();
|
|
2717
2802
|
await db.schema.dropIndex("idx_taxonomies_name_locale").ifExists().execute();
|
|
2718
2803
|
}
|
|
@@ -2720,8 +2805,8 @@ async function down$70(db) {
|
|
|
2720
2805
|
//#endregion
|
|
2721
2806
|
//#region src/database/migrations/053_restore_content_taxonomies_term_index.ts
|
|
2722
2807
|
var _053_restore_content_taxonomies_term_index_exports = /* @__PURE__ */ __exportAll({
|
|
2723
|
-
down: () => down$
|
|
2724
|
-
up: () => up$
|
|
2808
|
+
down: () => down$70,
|
|
2809
|
+
up: () => up$70
|
|
2725
2810
|
});
|
|
2726
2811
|
/**
|
|
2727
2812
|
* Restore the reverse lookup index on content taxonomy assignments.
|
|
@@ -2730,16 +2815,16 @@ var _053_restore_content_taxonomies_term_index_exports = /* @__PURE__ */ __expor
|
|
|
2730
2815
|
* covers upgraded SQLite databases that already recorded the table rebuild but
|
|
2731
2816
|
* ended up missing only this index.
|
|
2732
2817
|
*/
|
|
2733
|
-
async function up$
|
|
2818
|
+
async function up$70(db) {
|
|
2734
2819
|
await db.schema.createIndex("idx_content_taxonomies_term").ifNotExists().on("content_taxonomies").column("taxonomy_id").execute();
|
|
2735
2820
|
}
|
|
2736
|
-
async function down$
|
|
2821
|
+
async function down$70(db) {}
|
|
2737
2822
|
|
|
2738
2823
|
//#endregion
|
|
2739
2824
|
//#region src/database/migrations/054_restore_taxonomy_parent_index.ts
|
|
2740
2825
|
var _054_restore_taxonomy_parent_index_exports = /* @__PURE__ */ __exportAll({
|
|
2741
|
-
down: () => down$
|
|
2742
|
-
up: () => up$
|
|
2826
|
+
down: () => down$69,
|
|
2827
|
+
up: () => up$69
|
|
2743
2828
|
});
|
|
2744
2829
|
/**
|
|
2745
2830
|
* Restore the parent lookup index on hierarchical taxonomy terms.
|
|
@@ -2748,16 +2833,16 @@ var _054_restore_taxonomy_parent_index_exports = /* @__PURE__ */ __exportAll({
|
|
|
2748
2833
|
* could drop it on upgraded databases. Fresh installs recreate it in the
|
|
2749
2834
|
* rebuild path; this forward repair covers already-migrated databases.
|
|
2750
2835
|
*/
|
|
2751
|
-
async function up$
|
|
2836
|
+
async function up$69(db) {
|
|
2752
2837
|
await db.schema.createIndex("idx_taxonomies_parent").ifNotExists().on("taxonomies").column("parent_id").execute();
|
|
2753
2838
|
}
|
|
2754
|
-
async function down$
|
|
2839
|
+
async function down$69(db) {}
|
|
2755
2840
|
|
|
2756
2841
|
//#endregion
|
|
2757
2842
|
//#region src/database/migrations/055_taxonomy_parent_group.ts
|
|
2758
2843
|
var _055_taxonomy_parent_group_exports = /* @__PURE__ */ __exportAll({
|
|
2759
|
-
down: () => down$
|
|
2760
|
-
up: () => up$
|
|
2844
|
+
down: () => down$68,
|
|
2845
|
+
up: () => up$68
|
|
2761
2846
|
});
|
|
2762
2847
|
/**
|
|
2763
2848
|
* Store the parent's `translation_group` in `taxonomies.parent_id` instead of a
|
|
@@ -2772,7 +2857,7 @@ var _055_taxonomy_parent_group_exports = /* @__PURE__ */ __exportAll({
|
|
|
2772
2857
|
* anchor row's id. Only rewrite when that anchor row exists; otherwise keep the
|
|
2773
2858
|
* existing row id rather than writing a dangling FK value.
|
|
2774
2859
|
*/
|
|
2775
|
-
async function up$
|
|
2860
|
+
async function up$68(db) {
|
|
2776
2861
|
await sql`
|
|
2777
2862
|
UPDATE taxonomies
|
|
2778
2863
|
SET parent_id = (
|
|
@@ -2799,7 +2884,7 @@ async function up$67(db) {
|
|
|
2799
2884
|
* Rows with no same-locale parent are left as-is so rollback does not silently
|
|
2800
2885
|
* detach a subtree.
|
|
2801
2886
|
*/
|
|
2802
|
-
async function down$
|
|
2887
|
+
async function down$68(db) {
|
|
2803
2888
|
await sql`
|
|
2804
2889
|
UPDATE taxonomies
|
|
2805
2890
|
SET parent_id = COALESCE(
|
|
@@ -2818,8 +2903,8 @@ async function down$67(db) {
|
|
|
2818
2903
|
//#endregion
|
|
2819
2904
|
//#region src/database/migrations/056_media_usage_index.ts
|
|
2820
2905
|
var _056_media_usage_index_exports = /* @__PURE__ */ __exportAll({
|
|
2821
|
-
down: () => down$
|
|
2822
|
-
up: () => up$
|
|
2906
|
+
down: () => down$67,
|
|
2907
|
+
up: () => up$67
|
|
2823
2908
|
});
|
|
2824
2909
|
/**
|
|
2825
2910
|
* Internal media usage projection tables.
|
|
@@ -2828,7 +2913,7 @@ var _056_media_usage_index_exports = /* @__PURE__ */ __exportAll({
|
|
|
2828
2913
|
* imports, and no content-table scans. Production rows are introduced by later
|
|
2829
2914
|
* phases once the central snapshot/indexer path is reviewed.
|
|
2830
2915
|
*/
|
|
2831
|
-
async function up$
|
|
2916
|
+
async function up$67(db) {
|
|
2832
2917
|
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
2918
|
await db.schema.createIndex("idx__dineway_media_usage_sources_content").ifNotExists().on("_dineway_media_usage_sources").columns([
|
|
2834
2919
|
"source_type",
|
|
@@ -2850,7 +2935,7 @@ async function up$66(db) {
|
|
|
2850
2935
|
await db.schema.createIndex("idx__dineway_media_usage_provider_asset").ifNotExists().on("_dineway_media_usage").columns(["provider", "provider_asset_id"]).execute();
|
|
2851
2936
|
await db.schema.createIndex("idx__dineway_media_usage_source_generation").ifNotExists().on("_dineway_media_usage").columns(["source_key", "generation"]).execute();
|
|
2852
2937
|
}
|
|
2853
|
-
async function down$
|
|
2938
|
+
async function down$67(db) {
|
|
2854
2939
|
await db.schema.dropTable("_dineway_media_usage").ifExists().execute();
|
|
2855
2940
|
await db.schema.dropTable("_dineway_media_usage_sources").ifExists().execute();
|
|
2856
2941
|
}
|
|
@@ -2858,8 +2943,8 @@ async function down$66(db) {
|
|
|
2858
2943
|
//#endregion
|
|
2859
2944
|
//#region src/database/migrations/057_media_usage_index_status.ts
|
|
2860
2945
|
var _057_media_usage_index_status_exports = /* @__PURE__ */ __exportAll({
|
|
2861
|
-
down: () => down$
|
|
2862
|
-
up: () => up$
|
|
2946
|
+
down: () => down$66,
|
|
2947
|
+
up: () => up$66
|
|
2863
2948
|
});
|
|
2864
2949
|
const SOURCE_TABLE = "_dineway_media_usage_sources";
|
|
2865
2950
|
const DUPLICATE_COLUMN_RE = /(?:duplicate column|column .* already exists|already exists.*column)/i;
|
|
@@ -2869,7 +2954,7 @@ const DUPLICATE_COLUMN_RE = /(?:duplicate column|column .* already exists|alread
|
|
|
2869
2954
|
* DDL-only by design: adds source metadata and adapter-scope status tracking
|
|
2870
2955
|
* without scanning content tables or importing runtime code.
|
|
2871
2956
|
*/
|
|
2872
|
-
async function up$
|
|
2957
|
+
async function up$66(db) {
|
|
2873
2958
|
await addSourceMetadataColumns(db);
|
|
2874
2959
|
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
2960
|
"adapter_id",
|
|
@@ -2884,7 +2969,7 @@ async function up$65(db) {
|
|
|
2884
2969
|
await db.schema.createIndex("idx__dineway_media_usage_sources_fingerprint").ifNotExists().on("_dineway_media_usage_sources").column("source_fingerprint").execute();
|
|
2885
2970
|
await db.schema.createIndex("idx__dineway_media_usage_index_status_status").ifNotExists().on("_dineway_media_usage_index_status").columns(["adapter_id", "status"]).execute();
|
|
2886
2971
|
}
|
|
2887
|
-
async function down$
|
|
2972
|
+
async function down$66(db) {
|
|
2888
2973
|
await db.schema.dropIndex("idx__dineway_media_usage_index_status_status").ifExists().execute();
|
|
2889
2974
|
await db.schema.dropIndex("idx__dineway_media_usage_sources_fingerprint").ifExists().execute();
|
|
2890
2975
|
await db.schema.dropIndex("idx__dineway_media_usage_sources_completeness").ifExists().execute();
|
|
@@ -2940,10 +3025,10 @@ async function dropSourceMetadataColumns(db) {
|
|
|
2940
3025
|
//#endregion
|
|
2941
3026
|
//#region src/database/migrations/058_comment_reactions.ts
|
|
2942
3027
|
var _058_comment_reactions_exports = /* @__PURE__ */ __exportAll({
|
|
2943
|
-
down: () => down$
|
|
2944
|
-
up: () => up$
|
|
3028
|
+
down: () => down$65,
|
|
3029
|
+
up: () => up$65
|
|
2945
3030
|
});
|
|
2946
|
-
async function up$
|
|
3031
|
+
async function up$65(db) {
|
|
2947
3032
|
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
3033
|
await db.schema.createIndex("idx_dineway_comment_reactions_unique").on("_dineway_comment_reactions").columns([
|
|
2949
3034
|
"comment_id",
|
|
@@ -2953,15 +3038,15 @@ async function up$64(db) {
|
|
|
2953
3038
|
await db.schema.createIndex("idx_dineway_comment_reactions_comment_id").on("_dineway_comment_reactions").column("comment_id").execute();
|
|
2954
3039
|
await db.schema.createIndex("idx_dineway_comment_reactions_voter_recent").on("_dineway_comment_reactions").columns(["voter_hash", "created_at"]).execute();
|
|
2955
3040
|
}
|
|
2956
|
-
async function down$
|
|
3041
|
+
async function down$65(db) {
|
|
2957
3042
|
await db.schema.dropTable("_dineway_comment_reactions").execute();
|
|
2958
3043
|
}
|
|
2959
3044
|
|
|
2960
3045
|
//#endregion
|
|
2961
3046
|
//#region src/database/migrations/059_hitl_executions.ts
|
|
2962
3047
|
var _059_hitl_executions_exports = /* @__PURE__ */ __exportAll({
|
|
2963
|
-
down: () => down$
|
|
2964
|
-
up: () => up$
|
|
3048
|
+
down: () => down$64,
|
|
3049
|
+
up: () => up$64
|
|
2965
3050
|
});
|
|
2966
3051
|
const ACTOR_TYPES$1 = [
|
|
2967
3052
|
"user",
|
|
@@ -2975,7 +3060,7 @@ const EXECUTION_STATUSES = [
|
|
|
2975
3060
|
"failed",
|
|
2976
3061
|
"indeterminate"
|
|
2977
3062
|
];
|
|
2978
|
-
async function up$
|
|
3063
|
+
async function up$64(db) {
|
|
2979
3064
|
const actorTypesSql = sql.join(ACTOR_TYPES$1.map((value) => sql.lit(value)), sql`, `);
|
|
2980
3065
|
const reviewModesSql = sql.join(REVIEW_MODES.map((value) => sql.lit(value)), sql`, `);
|
|
2981
3066
|
const statusesSql = sql.join(EXECUTION_STATUSES.map((value) => sql.lit(value)), sql`, `);
|
|
@@ -3000,31 +3085,31 @@ async function up$63(db) {
|
|
|
3000
3085
|
"created_at"
|
|
3001
3086
|
]).execute();
|
|
3002
3087
|
}
|
|
3003
|
-
async function down$
|
|
3088
|
+
async function down$64(db) {
|
|
3004
3089
|
await db.schema.dropTable("_dineway_hitl_executions").ifExists().execute();
|
|
3005
3090
|
}
|
|
3006
3091
|
|
|
3007
3092
|
//#endregion
|
|
3008
3093
|
//#region src/database/migrations/060_plugin_secrets.ts
|
|
3009
3094
|
var _060_plugin_secrets_exports = /* @__PURE__ */ __exportAll({
|
|
3010
|
-
down: () => down$
|
|
3011
|
-
up: () => up$
|
|
3095
|
+
down: () => down$63,
|
|
3096
|
+
up: () => up$63
|
|
3012
3097
|
});
|
|
3013
|
-
async function up$
|
|
3098
|
+
async function up$63(db) {
|
|
3014
3099
|
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
3100
|
await db.schema.createIndex("idx_dineway_plugin_secrets_plugin_updated").on("_dineway_plugin_secrets").columns(["plugin_id", "updated_at"]).execute();
|
|
3016
3101
|
}
|
|
3017
|
-
async function down$
|
|
3102
|
+
async function down$63(db) {
|
|
3018
3103
|
await db.schema.dropTable("_dineway_plugin_secrets").execute();
|
|
3019
3104
|
}
|
|
3020
3105
|
|
|
3021
3106
|
//#endregion
|
|
3022
3107
|
//#region src/database/migrations/061_restaurant_locations.ts
|
|
3023
3108
|
var _061_restaurant_locations_exports = /* @__PURE__ */ __exportAll({
|
|
3024
|
-
down: () => down$
|
|
3025
|
-
up: () => up$
|
|
3109
|
+
down: () => down$62,
|
|
3110
|
+
up: () => up$62
|
|
3026
3111
|
});
|
|
3027
|
-
async function up$
|
|
3112
|
+
async function up$62(db) {
|
|
3028
3113
|
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
3114
|
await db.schema.createIndex("idx_restaurant_locations_status").on("restaurant_locations").column("status").execute();
|
|
3030
3115
|
await db.schema.createIndex("idx_restaurant_locations_created_at").on("restaurant_locations").column("created_at").execute();
|
|
@@ -3033,7 +3118,7 @@ async function up$61(db) {
|
|
|
3033
3118
|
await db.schema.createIndex("idx_restaurant_location_memberships_user_id").on("restaurant_location_memberships").column("user_id").execute();
|
|
3034
3119
|
await db.schema.createIndex("idx_restaurant_location_memberships_location_id").on("restaurant_location_memberships").column("location_id").execute();
|
|
3035
3120
|
}
|
|
3036
|
-
async function down$
|
|
3121
|
+
async function down$62(db) {
|
|
3037
3122
|
await db.schema.dropTable("restaurant_location_memberships").execute();
|
|
3038
3123
|
await db.schema.dropTable("restaurant_locations").execute();
|
|
3039
3124
|
}
|
|
@@ -3041,10 +3126,10 @@ async function down$61(db) {
|
|
|
3041
3126
|
//#endregion
|
|
3042
3127
|
//#region src/database/migrations/062_restaurant_menus.ts
|
|
3043
3128
|
var _062_restaurant_menus_exports = /* @__PURE__ */ __exportAll({
|
|
3044
|
-
down: () => down$
|
|
3045
|
-
up: () => up$
|
|
3129
|
+
down: () => down$61,
|
|
3130
|
+
up: () => up$61
|
|
3046
3131
|
});
|
|
3047
|
-
async function up$
|
|
3132
|
+
async function up$61(db) {
|
|
3048
3133
|
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
3134
|
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
3135
|
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 +3372,7 @@ async function createIndexes$9(db) {
|
|
|
3287
3372
|
]
|
|
3288
3373
|
]) await db.schema.createIndex(name).on(table).columns([...columns]).execute();
|
|
3289
3374
|
}
|
|
3290
|
-
async function down$
|
|
3375
|
+
async function down$61(db) {
|
|
3291
3376
|
await db.schema.dropTable("restaurant_menu_overrides").execute();
|
|
3292
3377
|
await db.schema.dropTable("restaurant_menu_item_translations").execute();
|
|
3293
3378
|
await db.schema.dropTable("restaurant_menu_item_modifier_groups").execute();
|
|
@@ -3303,11 +3388,11 @@ async function down$60(db) {
|
|
|
3303
3388
|
//#endregion
|
|
3304
3389
|
//#region src/database/migrations/063_restaurant_hours.ts
|
|
3305
3390
|
var _063_restaurant_hours_exports = /* @__PURE__ */ __exportAll({
|
|
3306
|
-
down: () => down$
|
|
3307
|
-
up: () => up$
|
|
3391
|
+
down: () => down$60,
|
|
3392
|
+
up: () => up$60
|
|
3308
3393
|
});
|
|
3309
3394
|
const SERVICE_SCOPE_CHECK = sql`service_scope in ('all', 'dine_in', 'pickup', 'delivery', 'reservations')`;
|
|
3310
|
-
async function up$
|
|
3395
|
+
async function up$60(db) {
|
|
3311
3396
|
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
3397
|
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
3398
|
"location_id",
|
|
@@ -3436,7 +3521,7 @@ async function createIndexes$8(db) {
|
|
|
3436
3521
|
"ends_at"
|
|
3437
3522
|
]).execute();
|
|
3438
3523
|
}
|
|
3439
|
-
async function down$
|
|
3524
|
+
async function down$60(db) {
|
|
3440
3525
|
await db.schema.dropTable("restaurant_closures").execute();
|
|
3441
3526
|
await db.schema.dropTable("restaurant_special_hours").execute();
|
|
3442
3527
|
await db.schema.dropTable("restaurant_hours_overrides").execute();
|
|
@@ -3446,14 +3531,14 @@ async function down$59(db) {
|
|
|
3446
3531
|
//#endregion
|
|
3447
3532
|
//#region src/database/migrations/064_restaurant_reservations.ts
|
|
3448
3533
|
var _064_restaurant_reservations_exports = /* @__PURE__ */ __exportAll({
|
|
3449
|
-
down: () => down$
|
|
3450
|
-
up: () => up$
|
|
3534
|
+
down: () => down$59,
|
|
3535
|
+
up: () => up$59
|
|
3451
3536
|
});
|
|
3452
3537
|
const RESERVATION_STATUS_CHECK = sql`status in ('pending', 'confirmed', 'seated', 'completed', 'cancelled', 'no_show')`;
|
|
3453
3538
|
const RESERVATION_SOURCE_CHECK = sql`source in ('public', 'admin', 'mcp', 'import')`;
|
|
3454
3539
|
const HOLD_STATUS_CHECK = sql`status in ('active', 'committed', 'released', 'expired')`;
|
|
3455
3540
|
const ACTIVE_REMOVED_STATUS_CHECK = sql`status in ('active', 'removed')`;
|
|
3456
|
-
async function up$
|
|
3541
|
+
async function up$59(db) {
|
|
3457
3542
|
await createSettingsTables(db);
|
|
3458
3543
|
await createFloorTables(db);
|
|
3459
3544
|
await createReservationTables(db);
|
|
@@ -3812,7 +3897,7 @@ async function createIndexes$7(db) {
|
|
|
3812
3897
|
WHERE status = 'active'
|
|
3813
3898
|
`.execute(db);
|
|
3814
3899
|
}
|
|
3815
|
-
async function down$
|
|
3900
|
+
async function down$59(db) {
|
|
3816
3901
|
await db.schema.dropTable("restaurant_guest_access").execute();
|
|
3817
3902
|
await db.schema.dropTable("restaurant_reservation_table_assignments").execute();
|
|
3818
3903
|
await db.schema.dropTable("restaurant_reservation_holds").execute();
|
|
@@ -3828,8 +3913,8 @@ async function down$58(db) {
|
|
|
3828
3913
|
//#endregion
|
|
3829
3914
|
//#region src/database/migrations/065_restaurant_orders.ts
|
|
3830
3915
|
var _065_restaurant_orders_exports = /* @__PURE__ */ __exportAll({
|
|
3831
|
-
down: () => down$
|
|
3832
|
-
up: () => up$
|
|
3916
|
+
down: () => down$58,
|
|
3917
|
+
up: () => up$58
|
|
3833
3918
|
});
|
|
3834
3919
|
const ORDER_STATUS_CHECK = sql`status in ('pending_payment', 'confirmed', 'preparing', 'ready', 'out_for_delivery', 'completed', 'cancelled')`;
|
|
3835
3920
|
const ORDER_SOURCE_CHECK = sql`source in ('public', 'admin', 'mcp', 'import', 'qr')`;
|
|
@@ -3838,7 +3923,7 @@ const PAYMENT_STATUS_CHECK = sql`status in ('requires_action', 'processing', 'au
|
|
|
3838
3923
|
const REFUND_STATUS_CHECK = sql`status in ('pending', 'succeeded', 'failed', 'cancelled')`;
|
|
3839
3924
|
const CART_HOLD_STATUS_CHECK = sql`status in ('active', 'committed', 'released', 'expired')`;
|
|
3840
3925
|
const ACTOR_TYPE_CHECK = sql`actor_type in ('user', 'api_token', 'system')`;
|
|
3841
|
-
async function up$
|
|
3926
|
+
async function up$58(db) {
|
|
3842
3927
|
await createOrderTables$1(db);
|
|
3843
3928
|
await createPaymentTables$1(db);
|
|
3844
3929
|
await createIndexes$6(db);
|
|
@@ -4175,7 +4260,7 @@ async function createImmutableLedgerTriggers(db) {
|
|
|
4175
4260
|
`.execute(db);
|
|
4176
4261
|
}
|
|
4177
4262
|
}
|
|
4178
|
-
async function down$
|
|
4263
|
+
async function down$58(db) {
|
|
4179
4264
|
await db.schema.dropTable("restaurant_refunds").execute();
|
|
4180
4265
|
await db.schema.dropTable("restaurant_payments").execute();
|
|
4181
4266
|
await db.schema.dropTable("restaurant_cart_holds").execute();
|
|
@@ -4190,10 +4275,10 @@ async function down$57(db) {
|
|
|
4190
4275
|
//#endregion
|
|
4191
4276
|
//#region src/database/migrations/066_restaurant_stripe_configuration.ts
|
|
4192
4277
|
var _066_restaurant_stripe_configuration_exports = /* @__PURE__ */ __exportAll({
|
|
4193
|
-
down: () => down$
|
|
4194
|
-
up: () => up$
|
|
4278
|
+
down: () => down$57,
|
|
4279
|
+
up: () => up$57
|
|
4195
4280
|
});
|
|
4196
|
-
async function up$
|
|
4281
|
+
async function up$57(db) {
|
|
4197
4282
|
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
4283
|
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
4284
|
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 +4345,7 @@ async function up$56(db) {
|
|
|
4260
4345
|
"tax_code"
|
|
4261
4346
|
]).execute();
|
|
4262
4347
|
}
|
|
4263
|
-
async function down$
|
|
4348
|
+
async function down$57(db) {
|
|
4264
4349
|
await db.schema.dropTable("restaurant_stripe_manual_tax_rates").execute();
|
|
4265
4350
|
await db.schema.dropTable("restaurant_stripe_location_settings").execute();
|
|
4266
4351
|
await db.schema.dropTable("restaurant_stripe_settings").execute();
|
|
@@ -4269,10 +4354,10 @@ async function down$56(db) {
|
|
|
4269
4354
|
//#endregion
|
|
4270
4355
|
//#region src/database/migrations/067_restaurant_payment_requested_amount.ts
|
|
4271
4356
|
var _067_restaurant_payment_requested_amount_exports = /* @__PURE__ */ __exportAll({
|
|
4272
|
-
down: () => down$
|
|
4273
|
-
up: () => up$
|
|
4357
|
+
down: () => down$56,
|
|
4358
|
+
up: () => up$56
|
|
4274
4359
|
});
|
|
4275
|
-
async function up$
|
|
4360
|
+
async function up$56(db) {
|
|
4276
4361
|
await db.schema.alterTable("restaurant_payments").addColumn("amount_requested_minor", "integer", (column) => column.notNull().defaultTo(0).check(sql`amount_requested_minor >= 0`)).execute();
|
|
4277
4362
|
await sql`
|
|
4278
4363
|
UPDATE restaurant_payments
|
|
@@ -4288,19 +4373,19 @@ async function up$55(db) {
|
|
|
4288
4373
|
WHERE amount_requested_minor = 0
|
|
4289
4374
|
`.execute(db);
|
|
4290
4375
|
}
|
|
4291
|
-
async function down$
|
|
4376
|
+
async function down$56(db) {
|
|
4292
4377
|
await db.schema.alterTable("restaurant_payments").dropColumn("amount_requested_minor").execute();
|
|
4293
4378
|
}
|
|
4294
4379
|
|
|
4295
4380
|
//#endregion
|
|
4296
4381
|
//#region src/database/migrations/068_restaurant_stripe_events.ts
|
|
4297
4382
|
var _068_restaurant_stripe_events_exports = /* @__PURE__ */ __exportAll({
|
|
4298
|
-
down: () => down$
|
|
4299
|
-
up: () => up$
|
|
4383
|
+
down: () => down$55,
|
|
4384
|
+
up: () => up$55
|
|
4300
4385
|
});
|
|
4301
4386
|
const currentTimestamp = sql`(datetime('now'))`;
|
|
4302
4387
|
const retentionTimestamp = sql`(datetime('now', '+30 days'))`;
|
|
4303
|
-
async function up$
|
|
4388
|
+
async function up$55(db) {
|
|
4304
4389
|
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
4390
|
for (const [name, column] of [
|
|
4306
4391
|
["idx_restaurant_stripe_events_status", "status"],
|
|
@@ -4317,22 +4402,22 @@ async function up$54(db) {
|
|
|
4317
4402
|
"id"
|
|
4318
4403
|
]).execute();
|
|
4319
4404
|
}
|
|
4320
|
-
async function down$
|
|
4405
|
+
async function down$55(db) {
|
|
4321
4406
|
await db.schema.dropTable("restaurant_stripe_events").execute();
|
|
4322
4407
|
}
|
|
4323
4408
|
|
|
4324
4409
|
//#endregion
|
|
4325
4410
|
//#region src/database/migrations/069_restaurant_tax_behavior.ts
|
|
4326
4411
|
var _069_restaurant_tax_behavior_exports = /* @__PURE__ */ __exportAll({
|
|
4327
|
-
down: () => down$
|
|
4328
|
-
up: () => up$
|
|
4412
|
+
down: () => down$54,
|
|
4413
|
+
up: () => up$54
|
|
4329
4414
|
});
|
|
4330
|
-
async function up$
|
|
4415
|
+
async function up$54(db) {
|
|
4331
4416
|
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
4417
|
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
4418
|
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
4419
|
}
|
|
4335
|
-
async function down$
|
|
4420
|
+
async function down$54(db) {
|
|
4336
4421
|
await db.schema.alterTable("restaurant_menu_items").dropColumn("tax_behavior").execute();
|
|
4337
4422
|
await db.schema.alterTable("restaurant_stripe_location_settings").dropColumn("tax_behavior").execute();
|
|
4338
4423
|
await db.schema.alterTable("restaurant_stripe_settings").dropColumn("default_tax_behavior").execute();
|
|
@@ -4341,15 +4426,15 @@ async function down$53(db) {
|
|
|
4341
4426
|
//#endregion
|
|
4342
4427
|
//#region src/database/migrations/070_restaurant_inclusive_order_item_totals.ts
|
|
4343
4428
|
var _070_restaurant_inclusive_order_item_totals_exports = /* @__PURE__ */ __exportAll({
|
|
4344
|
-
down: () => down$
|
|
4345
|
-
up: () => up$
|
|
4429
|
+
down: () => down$53,
|
|
4430
|
+
up: () => up$53
|
|
4346
4431
|
});
|
|
4347
4432
|
const REBUILT_ORDER_ITEMS = "_restaurant_order_items_rebuild";
|
|
4348
4433
|
const REBUILT_ORDER_ITEM_MODIFIERS = "_restaurant_order_item_modifiers_rebuild";
|
|
4349
|
-
async function up$
|
|
4434
|
+
async function up$53(db) {
|
|
4350
4435
|
await rebuildOrderItemLedger(db, true);
|
|
4351
4436
|
}
|
|
4352
|
-
async function down$
|
|
4437
|
+
async function down$53(db) {
|
|
4353
4438
|
await rebuildOrderItemLedger(db, false);
|
|
4354
4439
|
}
|
|
4355
4440
|
async function rebuildOrderItemLedger(db, inclusiveAware) {
|
|
@@ -4472,11 +4557,11 @@ async function createImmutableTriggers(db) {
|
|
|
4472
4557
|
//#endregion
|
|
4473
4558
|
//#region src/database/migrations/071_restaurant_delivery_zones.ts
|
|
4474
4559
|
var _071_restaurant_delivery_zones_exports = /* @__PURE__ */ __exportAll({
|
|
4475
|
-
down: () => down$
|
|
4476
|
-
up: () => up$
|
|
4560
|
+
down: () => down$52,
|
|
4561
|
+
up: () => up$52
|
|
4477
4562
|
});
|
|
4478
4563
|
const DELIVERY_ZONE_STATUS_CHECK = sql`status in ('active', 'archived')`;
|
|
4479
|
-
async function up$
|
|
4564
|
+
async function up$52(db) {
|
|
4480
4565
|
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
4566
|
await db.schema.createIndex("idx_restaurant_delivery_zones_location_status_priority").on("restaurant_delivery_zones").columns([
|
|
4482
4567
|
"location_id",
|
|
@@ -4485,35 +4570,35 @@ async function up$51(db) {
|
|
|
4485
4570
|
"id"
|
|
4486
4571
|
]).execute();
|
|
4487
4572
|
}
|
|
4488
|
-
async function down$
|
|
4573
|
+
async function down$52(db) {
|
|
4489
4574
|
await db.schema.dropTable("restaurant_delivery_zones").execute();
|
|
4490
4575
|
}
|
|
4491
4576
|
|
|
4492
4577
|
//#endregion
|
|
4493
4578
|
//#region src/database/migrations/072_restaurant_delivery_settings.ts
|
|
4494
4579
|
var _072_restaurant_delivery_settings_exports = /* @__PURE__ */ __exportAll({
|
|
4495
|
-
down: () => down$
|
|
4496
|
-
up: () => up$
|
|
4580
|
+
down: () => down$51,
|
|
4581
|
+
up: () => up$51
|
|
4497
4582
|
});
|
|
4498
4583
|
const SLOT_MINUTES_CHECK = sql`slot_minutes between 5 and 120 and slot_minutes % 5 = 0`;
|
|
4499
|
-
async function up$
|
|
4584
|
+
async function up$51(db) {
|
|
4500
4585
|
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
4586
|
await db.schema.createIndex("idx_restaurant_delivery_settings_location_id").on("restaurant_delivery_settings").column("location_id").execute();
|
|
4502
4587
|
}
|
|
4503
|
-
async function down$
|
|
4588
|
+
async function down$51(db) {
|
|
4504
4589
|
await db.schema.dropTable("restaurant_delivery_settings").execute();
|
|
4505
4590
|
}
|
|
4506
4591
|
|
|
4507
4592
|
//#endregion
|
|
4508
4593
|
//#region src/database/migrations/073_restaurant_dine_in.ts
|
|
4509
4594
|
var _073_restaurant_dine_in_exports = /* @__PURE__ */ __exportAll({
|
|
4510
|
-
down: () => down$
|
|
4511
|
-
up: () => up$
|
|
4595
|
+
down: () => down$50,
|
|
4596
|
+
up: () => up$50
|
|
4512
4597
|
});
|
|
4513
4598
|
const SESSION_STATUS_CHECK = sql`status in ('open', 'closed', 'cancelled')`;
|
|
4514
4599
|
const ROUND_PAYMENT_MODE_CHECK = sql`payment_mode in ('prepaid', 'offline', 'tab')`;
|
|
4515
4600
|
const ROUND_STATUS_CHECK = sql`status in ('open', 'authorized', 'settled', 'voided')`;
|
|
4516
|
-
async function up$
|
|
4601
|
+
async function up$50(db) {
|
|
4517
4602
|
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
4603
|
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
4604
|
await db.schema.createIndex("idx_restaurant_dine_in_sessions_location_id").on("restaurant_dine_in_sessions").column("location_id").execute();
|
|
@@ -4541,7 +4626,7 @@ async function up$49(db) {
|
|
|
4541
4626
|
WHERE status = 'open'
|
|
4542
4627
|
`.execute(db);
|
|
4543
4628
|
}
|
|
4544
|
-
async function down$
|
|
4629
|
+
async function down$50(db) {
|
|
4545
4630
|
await db.schema.dropTable("restaurant_tab_rounds").execute();
|
|
4546
4631
|
await db.schema.dropTable("restaurant_dine_in_sessions").execute();
|
|
4547
4632
|
}
|
|
@@ -4549,11 +4634,11 @@ async function down$49(db) {
|
|
|
4549
4634
|
//#endregion
|
|
4550
4635
|
//#region src/database/migrations/074_restaurant_outbox.ts
|
|
4551
4636
|
var _074_restaurant_outbox_exports = /* @__PURE__ */ __exportAll({
|
|
4552
|
-
down: () => down$
|
|
4553
|
-
up: () => up$
|
|
4637
|
+
down: () => down$49,
|
|
4638
|
+
up: () => up$49
|
|
4554
4639
|
});
|
|
4555
4640
|
const OUTBOX_STATUS_CHECK = sql`status in ('pending', 'processing', 'delivered', 'failed')`;
|
|
4556
|
-
async function up$
|
|
4641
|
+
async function up$49(db) {
|
|
4557
4642
|
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
4643
|
for (const [name, column] of [
|
|
4559
4644
|
["idx_restaurant_outbox_location_id", "location_id"],
|
|
@@ -4569,19 +4654,19 @@ async function up$48(db) {
|
|
|
4569
4654
|
"id"
|
|
4570
4655
|
]).execute();
|
|
4571
4656
|
}
|
|
4572
|
-
async function down$
|
|
4657
|
+
async function down$49(db) {
|
|
4573
4658
|
await db.schema.dropTable("restaurant_outbox_events").execute();
|
|
4574
4659
|
}
|
|
4575
4660
|
|
|
4576
4661
|
//#endregion
|
|
4577
4662
|
//#region src/database/migrations/075_restaurant_kds_tickets.ts
|
|
4578
4663
|
var _075_restaurant_kds_tickets_exports = /* @__PURE__ */ __exportAll({
|
|
4579
|
-
down: () => down$
|
|
4580
|
-
up: () => up$
|
|
4664
|
+
down: () => down$48,
|
|
4665
|
+
up: () => up$48
|
|
4581
4666
|
});
|
|
4582
4667
|
const FULFILMENT_TYPE_CHECK = sql`fulfilment_type in ('dine_in', 'pickup', 'delivery')`;
|
|
4583
4668
|
const KDS_STATUS_CHECK = sql`status in ('queued', 'preparing', 'ready', 'completed', 'cancelled')`;
|
|
4584
|
-
async function up$
|
|
4669
|
+
async function up$48(db) {
|
|
4585
4670
|
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
4671
|
for (const [name, column] of [
|
|
4587
4672
|
["idx_restaurant_kds_tickets_location_id", "location_id"],
|
|
@@ -4599,38 +4684,38 @@ async function up$47(db) {
|
|
|
4599
4684
|
"id"
|
|
4600
4685
|
]).execute();
|
|
4601
4686
|
}
|
|
4602
|
-
async function down$
|
|
4687
|
+
async function down$48(db) {
|
|
4603
4688
|
await db.schema.dropTable("restaurant_kds_tickets").execute();
|
|
4604
4689
|
}
|
|
4605
4690
|
|
|
4606
4691
|
//#endregion
|
|
4607
4692
|
//#region src/database/migrations/076_restaurant_notification_settings.ts
|
|
4608
4693
|
var _076_restaurant_notification_settings_exports = /* @__PURE__ */ __exportAll({
|
|
4609
|
-
down: () => down$
|
|
4610
|
-
up: () => up$
|
|
4694
|
+
down: () => down$47,
|
|
4695
|
+
up: () => up$47
|
|
4611
4696
|
});
|
|
4612
4697
|
const SCOPE_CHECK = sql`(
|
|
4613
4698
|
(location_id is null and scope_key = 'global') or
|
|
4614
4699
|
(location_id is not null and scope_key = ('location:' || location_id))
|
|
4615
4700
|
)`;
|
|
4616
|
-
async function up$
|
|
4701
|
+
async function up$47(db) {
|
|
4617
4702
|
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
4703
|
await db.schema.createIndex("idx_restaurant_notification_settings_location_id").on("restaurant_notification_settings").column("location_id").execute();
|
|
4619
4704
|
await db.schema.createIndex("idx_restaurant_notification_settings_updated_at").on("restaurant_notification_settings").column("updated_at").execute();
|
|
4620
4705
|
}
|
|
4621
|
-
async function down$
|
|
4706
|
+
async function down$47(db) {
|
|
4622
4707
|
await db.schema.dropTable("restaurant_notification_settings").execute();
|
|
4623
4708
|
}
|
|
4624
4709
|
|
|
4625
4710
|
//#endregion
|
|
4626
4711
|
//#region src/database/migrations/077_restaurant_outbox_deliveries.ts
|
|
4627
4712
|
var _077_restaurant_outbox_deliveries_exports = /* @__PURE__ */ __exportAll({
|
|
4628
|
-
down: () => down$
|
|
4629
|
-
up: () => up$
|
|
4713
|
+
down: () => down$46,
|
|
4714
|
+
up: () => up$46
|
|
4630
4715
|
});
|
|
4631
4716
|
const CHANNEL_CHECK = sql`channel in ('email', 'webhook', 'receipt', 'external_kds')`;
|
|
4632
4717
|
const DELIVERY_STATUS_CHECK = sql`status in ('pending', 'processing', 'delivered', 'failed')`;
|
|
4633
|
-
async function up$
|
|
4718
|
+
async function up$46(db) {
|
|
4634
4719
|
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
4720
|
await db.schema.createIndex("idx_restaurant_outbox_deliveries_event_id").on("restaurant_outbox_deliveries").column("event_id").execute();
|
|
4636
4721
|
await db.schema.createIndex("idx_restaurant_outbox_deliveries_channel").on("restaurant_outbox_deliveries").column("channel").execute();
|
|
@@ -4672,17 +4757,17 @@ async function up$45(db) {
|
|
|
4672
4757
|
ON CONFLICT (event_id, channel) DO NOTHING
|
|
4673
4758
|
`.execute(db);
|
|
4674
4759
|
}
|
|
4675
|
-
async function down$
|
|
4760
|
+
async function down$46(db) {
|
|
4676
4761
|
await db.schema.dropTable("restaurant_outbox_deliveries").execute();
|
|
4677
4762
|
}
|
|
4678
4763
|
|
|
4679
4764
|
//#endregion
|
|
4680
4765
|
//#region src/database/migrations/078_restaurant_external_kds_settings.ts
|
|
4681
4766
|
var _078_restaurant_external_kds_settings_exports = /* @__PURE__ */ __exportAll({
|
|
4682
|
-
down: () => down$
|
|
4683
|
-
up: () => up$
|
|
4767
|
+
down: () => down$45,
|
|
4768
|
+
up: () => up$45
|
|
4684
4769
|
});
|
|
4685
|
-
async function up$
|
|
4770
|
+
async function up$45(db) {
|
|
4686
4771
|
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
4772
|
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
4773
|
await db.schema.alterTable("restaurant_notification_settings").addColumn("external_kds_event_types_json", "text", (col) => col.notNull().defaultTo("[]")).execute();
|
|
@@ -4699,7 +4784,7 @@ async function up$44(db) {
|
|
|
4699
4784
|
ON CONFLICT (event_id, channel) DO NOTHING
|
|
4700
4785
|
`.execute(db);
|
|
4701
4786
|
}
|
|
4702
|
-
async function down$
|
|
4787
|
+
async function down$45(db) {
|
|
4703
4788
|
await db.schema.alterTable("restaurant_notification_settings").dropColumn("external_kds_event_types_json").execute();
|
|
4704
4789
|
await db.schema.alterTable("restaurant_notification_settings").dropColumn("external_kds_enabled").execute();
|
|
4705
4790
|
await db.schema.alterTable("restaurant_notification_settings").dropColumn("external_kds_url").execute();
|
|
@@ -4708,26 +4793,26 @@ async function down$44(db) {
|
|
|
4708
4793
|
//#endregion
|
|
4709
4794
|
//#region src/database/migrations/079_restaurant_dine_in_settings.ts
|
|
4710
4795
|
var _079_restaurant_dine_in_settings_exports = /* @__PURE__ */ __exportAll({
|
|
4711
|
-
down: () => down$
|
|
4712
|
-
up: () => up$
|
|
4796
|
+
down: () => down$44,
|
|
4797
|
+
up: () => up$44
|
|
4713
4798
|
});
|
|
4714
4799
|
const PAYMENT_MODE_CHECK = sql`default_payment_mode in ('prepaid', 'offline', 'tab')`;
|
|
4715
|
-
async function up$
|
|
4800
|
+
async function up$44(db) {
|
|
4716
4801
|
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
4802
|
await db.schema.createIndex("idx_restaurant_dine_in_settings_location_id").ifNotExists().on("restaurant_dine_in_settings").column("location_id").execute();
|
|
4718
4803
|
await db.schema.createIndex("idx_restaurant_dine_in_settings_updated_at").ifNotExists().on("restaurant_dine_in_settings").column("updated_at").execute();
|
|
4719
4804
|
}
|
|
4720
|
-
async function down$
|
|
4805
|
+
async function down$44(db) {
|
|
4721
4806
|
await db.schema.dropTable("restaurant_dine_in_settings").ifExists().execute();
|
|
4722
4807
|
}
|
|
4723
4808
|
|
|
4724
4809
|
//#endregion
|
|
4725
4810
|
//#region src/database/migrations/080_restaurant_operating_settings.ts
|
|
4726
4811
|
var _080_restaurant_operating_settings_exports = /* @__PURE__ */ __exportAll({
|
|
4727
|
-
down: () => down$
|
|
4728
|
-
up: () => up$
|
|
4812
|
+
down: () => down$43,
|
|
4813
|
+
up: () => up$43
|
|
4729
4814
|
});
|
|
4730
|
-
async function up$
|
|
4815
|
+
async function up$43(db) {
|
|
4731
4816
|
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
4817
|
location_id is null and scope_key = '*' and
|
|
4733
4818
|
default_currency is not null and default_timezone is not null and
|
|
@@ -4740,22 +4825,22 @@ async function up$42(db) {
|
|
|
4740
4825
|
await db.schema.createIndex("idx_restaurant_operating_settings_location_id").on("restaurant_operating_settings").column("location_id").execute();
|
|
4741
4826
|
await db.schema.createIndex("idx_restaurant_operating_settings_updated_at").on("restaurant_operating_settings").column("updated_at").execute();
|
|
4742
4827
|
}
|
|
4743
|
-
async function down$
|
|
4828
|
+
async function down$43(db) {
|
|
4744
4829
|
await db.schema.dropTable("restaurant_operating_settings").execute();
|
|
4745
4830
|
}
|
|
4746
4831
|
|
|
4747
4832
|
//#endregion
|
|
4748
4833
|
//#region src/database/migrations/081_restaurant_email_notification_settings.ts
|
|
4749
4834
|
var _081_restaurant_email_notification_settings_exports = /* @__PURE__ */ __exportAll({
|
|
4750
|
-
down: () => down$
|
|
4751
|
-
up: () => up$
|
|
4835
|
+
down: () => down$42,
|
|
4836
|
+
up: () => up$42
|
|
4752
4837
|
});
|
|
4753
|
-
async function up$
|
|
4838
|
+
async function up$42(db) {
|
|
4754
4839
|
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
4840
|
await db.schema.alterTable("restaurant_notification_settings").addColumn("email_event_types_json", "text", (col) => col.notNull().defaultTo("[]")).execute();
|
|
4756
4841
|
await db.schema.alterTable("restaurant_notification_settings").addColumn("email_templates_json", "text", (col) => col.notNull().defaultTo("{}")).execute();
|
|
4757
4842
|
}
|
|
4758
|
-
async function down$
|
|
4843
|
+
async function down$42(db) {
|
|
4759
4844
|
await db.schema.alterTable("restaurant_notification_settings").dropColumn("email_templates_json").execute();
|
|
4760
4845
|
await db.schema.alterTable("restaurant_notification_settings").dropColumn("email_event_types_json").execute();
|
|
4761
4846
|
await db.schema.alterTable("restaurant_notification_settings").dropColumn("email_enabled").execute();
|
|
@@ -4764,17 +4849,17 @@ async function down$41(db) {
|
|
|
4764
4849
|
//#endregion
|
|
4765
4850
|
//#region src/database/migrations/082_restaurant_reservation_checkout_holds.ts
|
|
4766
4851
|
var _082_restaurant_reservation_checkout_holds_exports = /* @__PURE__ */ __exportAll({
|
|
4767
|
-
down: () => down$
|
|
4768
|
-
up: () => up$
|
|
4852
|
+
down: () => down$41,
|
|
4853
|
+
up: () => up$41
|
|
4769
4854
|
});
|
|
4770
|
-
async function up$
|
|
4855
|
+
async function up$41(db) {
|
|
4771
4856
|
await db.schema.alterTable("restaurant_reservation_holds").addColumn("zone_id", "text", (col) => col.references("restaurant_zones.id").onDelete("set null")).execute();
|
|
4772
4857
|
await db.schema.alterTable("restaurant_reservation_holds").addColumn("token_id", "text").execute();
|
|
4773
4858
|
await db.schema.alterTable("restaurant_reservation_holds").addColumn("token_hash", "text").execute();
|
|
4774
4859
|
await db.schema.createIndex("idx_restaurant_reservation_holds_zone_id").on("restaurant_reservation_holds").column("zone_id").execute();
|
|
4775
4860
|
await db.schema.createIndex("idx_restaurant_reservation_holds_token_hash").unique().on("restaurant_reservation_holds").column("token_hash").execute();
|
|
4776
4861
|
}
|
|
4777
|
-
async function down$
|
|
4862
|
+
async function down$41(db) {
|
|
4778
4863
|
await db.schema.dropIndex("idx_restaurant_reservation_holds_token_hash").execute();
|
|
4779
4864
|
await db.schema.dropIndex("idx_restaurant_reservation_holds_zone_id").execute();
|
|
4780
4865
|
await db.schema.alterTable("restaurant_reservation_holds").dropColumn("token_hash").execute();
|
|
@@ -4785,10 +4870,10 @@ async function down$40(db) {
|
|
|
4785
4870
|
//#endregion
|
|
4786
4871
|
//#region src/database/migrations/083_restaurant_reservation_availability_indexes.ts
|
|
4787
4872
|
var _083_restaurant_reservation_availability_indexes_exports = /* @__PURE__ */ __exportAll({
|
|
4788
|
-
down: () => down$
|
|
4789
|
-
up: () => up$
|
|
4873
|
+
down: () => down$40,
|
|
4874
|
+
up: () => up$40
|
|
4790
4875
|
});
|
|
4791
|
-
async function up$
|
|
4876
|
+
async function up$40(db) {
|
|
4792
4877
|
await db.schema.createIndex("idx_restaurant_reservations_location_availability").on("restaurant_reservations").columns([
|
|
4793
4878
|
"location_id",
|
|
4794
4879
|
"status",
|
|
@@ -4803,7 +4888,7 @@ async function up$39(db) {
|
|
|
4803
4888
|
"expires_at"
|
|
4804
4889
|
]).execute();
|
|
4805
4890
|
}
|
|
4806
|
-
async function down$
|
|
4891
|
+
async function down$40(db) {
|
|
4807
4892
|
await db.schema.dropIndex("idx_restaurant_reservation_holds_location_availability").execute();
|
|
4808
4893
|
await db.schema.dropIndex("idx_restaurant_reservations_location_availability").execute();
|
|
4809
4894
|
}
|
|
@@ -4811,10 +4896,10 @@ async function down$39(db) {
|
|
|
4811
4896
|
//#endregion
|
|
4812
4897
|
//#region src/database/migrations/084_restaurant_reservation_demand.ts
|
|
4813
4898
|
var _084_restaurant_reservation_demand_exports = /* @__PURE__ */ __exportAll({
|
|
4814
|
-
down: () => down$
|
|
4815
|
-
up: () => up$
|
|
4899
|
+
down: () => down$39,
|
|
4900
|
+
up: () => up$39
|
|
4816
4901
|
});
|
|
4817
|
-
async function up$
|
|
4902
|
+
async function up$39(db) {
|
|
4818
4903
|
await createDemandSettings(db);
|
|
4819
4904
|
await createReservationRequests(db);
|
|
4820
4905
|
await createRequestTableAssignments(db);
|
|
@@ -4823,7 +4908,7 @@ async function up$38(db) {
|
|
|
4823
4908
|
await createPriorityAlertDeliveries(db);
|
|
4824
4909
|
await createIndexes$4(db);
|
|
4825
4910
|
}
|
|
4826
|
-
async function down$
|
|
4911
|
+
async function down$39(db) {
|
|
4827
4912
|
await db.schema.dropTable("restaurant_priority_alert_deliveries").execute();
|
|
4828
4913
|
await db.schema.dropTable("restaurant_priority_alert_opportunities").execute();
|
|
4829
4914
|
await db.schema.dropTable("restaurant_priority_alerts").execute();
|
|
@@ -4912,10 +4997,10 @@ async function createIndexes$4(db) {
|
|
|
4912
4997
|
//#endregion
|
|
4913
4998
|
//#region src/database/migrations/085_restaurant_reservation_offers.ts
|
|
4914
4999
|
var _085_restaurant_reservation_offers_exports = /* @__PURE__ */ __exportAll({
|
|
4915
|
-
down: () => down$
|
|
4916
|
-
up: () => up$
|
|
5000
|
+
down: () => down$38,
|
|
5001
|
+
up: () => up$38
|
|
4917
5002
|
});
|
|
4918
|
-
async function up$
|
|
5003
|
+
async function up$38(db) {
|
|
4919
5004
|
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
5005
|
or (payment_mode = 'charge' and amount_minor is not null and currency is not null)`).addCheckConstraint("ck_restaurant_reservation_offers_state", sql`(
|
|
4921
5006
|
(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 +5014,17 @@ async function up$37(db) {
|
|
|
4929
5014
|
await db.schema.createIndex("idx_restaurant_reservation_offers_status_expires").on("restaurant_reservation_offers").columns(["status", "expires_at"]).execute();
|
|
4930
5015
|
await db.schema.createIndex("idx_restaurant_reservation_offers_created_at").on("restaurant_reservation_offers").column("created_at").execute();
|
|
4931
5016
|
}
|
|
4932
|
-
async function down$
|
|
5017
|
+
async function down$38(db) {
|
|
4933
5018
|
await db.schema.dropTable("restaurant_reservation_offers").execute();
|
|
4934
5019
|
}
|
|
4935
5020
|
|
|
4936
5021
|
//#endregion
|
|
4937
5022
|
//#region src/database/migrations/086_restaurant_reservation_payment_policies.ts
|
|
4938
5023
|
var _086_restaurant_reservation_payment_policies_exports = /* @__PURE__ */ __exportAll({
|
|
4939
|
-
down: () => down$
|
|
4940
|
-
up: () => up$
|
|
5024
|
+
down: () => down$37,
|
|
5025
|
+
up: () => up$37
|
|
4941
5026
|
});
|
|
4942
|
-
async function up$
|
|
5027
|
+
async function up$37(db) {
|
|
4943
5028
|
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
5029
|
(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
5030
|
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 +5061,17 @@ async function up$36(db) {
|
|
|
4976
5061
|
]).execute();
|
|
4977
5062
|
await db.schema.createIndex("idx_restaurant_reservation_payment_policies_created_at").on("restaurant_reservation_payment_policies").column("created_at").execute();
|
|
4978
5063
|
}
|
|
4979
|
-
async function down$
|
|
5064
|
+
async function down$37(db) {
|
|
4980
5065
|
await db.schema.dropTable("restaurant_reservation_payment_policies").execute();
|
|
4981
5066
|
}
|
|
4982
5067
|
|
|
4983
5068
|
//#endregion
|
|
4984
5069
|
//#region src/database/migrations/087_restaurant_reservation_commercial_catalog.ts
|
|
4985
5070
|
var _087_restaurant_reservation_commercial_catalog_exports = /* @__PURE__ */ __exportAll({
|
|
4986
|
-
down: () => down$
|
|
4987
|
-
up: () => up$
|
|
5071
|
+
down: () => down$36,
|
|
5072
|
+
up: () => up$36
|
|
4988
5073
|
});
|
|
4989
|
-
async function up$
|
|
5074
|
+
async function up$36(db) {
|
|
4990
5075
|
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
5076
|
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
5077
|
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 +5154,7 @@ async function up$35(db) {
|
|
|
5069
5154
|
]
|
|
5070
5155
|
]) await db.schema.createIndex(name).on(table).columns([...columns]).execute();
|
|
5071
5156
|
}
|
|
5072
|
-
async function down$
|
|
5157
|
+
async function down$36(db) {
|
|
5073
5158
|
await db.schema.dropTable("restaurant_reservation_experience_included_addons").execute();
|
|
5074
5159
|
await db.schema.dropTable("restaurant_reservation_experience_addon_categories").execute();
|
|
5075
5160
|
await db.schema.dropTable("restaurant_reservation_addons").execute();
|
|
@@ -5080,10 +5165,10 @@ async function down$35(db) {
|
|
|
5080
5165
|
//#endregion
|
|
5081
5166
|
//#region src/database/migrations/088_restaurant_reservation_hold_commercial_allocations.ts
|
|
5082
5167
|
var _088_restaurant_reservation_hold_commercial_allocations_exports = /* @__PURE__ */ __exportAll({
|
|
5083
|
-
down: () => down$
|
|
5084
|
-
up: () => up$
|
|
5168
|
+
down: () => down$35,
|
|
5169
|
+
up: () => up$35
|
|
5085
5170
|
});
|
|
5086
|
-
async function up$
|
|
5171
|
+
async function up$35(db) {
|
|
5087
5172
|
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
5173
|
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
5174
|
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 +5232,7 @@ async function up$34(db) {
|
|
|
5147
5232
|
]
|
|
5148
5233
|
]) await db.schema.createIndex(name).on(table).columns([...columns]).execute();
|
|
5149
5234
|
}
|
|
5150
|
-
async function down$
|
|
5235
|
+
async function down$35(db) {
|
|
5151
5236
|
await db.schema.dropTable("restaurant_reservation_hold_addon_operations").execute();
|
|
5152
5237
|
await db.schema.dropTable("restaurant_reservation_hold_addons").execute();
|
|
5153
5238
|
await db.schema.dropTable("restaurant_reservation_hold_commercial_selections").execute();
|
|
@@ -5156,10 +5241,10 @@ async function down$34(db) {
|
|
|
5156
5241
|
//#endregion
|
|
5157
5242
|
//#region src/database/migrations/089_restaurant_reservation_quotes.ts
|
|
5158
5243
|
var _089_restaurant_reservation_quotes_exports = /* @__PURE__ */ __exportAll({
|
|
5159
|
-
down: () => down$
|
|
5160
|
-
up: () => up$
|
|
5244
|
+
down: () => down$34,
|
|
5245
|
+
up: () => up$34
|
|
5161
5246
|
});
|
|
5162
|
-
async function up$
|
|
5247
|
+
async function up$34(db) {
|
|
5163
5248
|
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
5249
|
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
5250
|
or (collection_mode = 'charge' and authorization_minor = 0)
|
|
@@ -5199,7 +5284,7 @@ async function up$33(db) {
|
|
|
5199
5284
|
]
|
|
5200
5285
|
]) await db.schema.createIndex(name).on(table).column(column).execute();
|
|
5201
5286
|
}
|
|
5202
|
-
async function down$
|
|
5287
|
+
async function down$34(db) {
|
|
5203
5288
|
await db.schema.dropTable("restaurant_reservation_quote_lines").execute();
|
|
5204
5289
|
await db.schema.dropTable("restaurant_reservation_quotes").execute();
|
|
5205
5290
|
}
|
|
@@ -5207,10 +5292,10 @@ async function down$33(db) {
|
|
|
5207
5292
|
//#endregion
|
|
5208
5293
|
//#region src/database/migrations/090_restaurant_reservation_quote_payments.ts
|
|
5209
5294
|
var _090_restaurant_reservation_quote_payments_exports = /* @__PURE__ */ __exportAll({
|
|
5210
|
-
down: () => down$
|
|
5211
|
-
up: () => up$
|
|
5295
|
+
down: () => down$33,
|
|
5296
|
+
up: () => up$33
|
|
5212
5297
|
});
|
|
5213
|
-
async function up$
|
|
5298
|
+
async function up$33(db) {
|
|
5214
5299
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
5215
5300
|
try {
|
|
5216
5301
|
await sql`
|
|
@@ -5285,7 +5370,7 @@ async function up$32(db) {
|
|
|
5285
5370
|
}
|
|
5286
5371
|
await assertForeignKeys$5(db);
|
|
5287
5372
|
}
|
|
5288
|
-
async function down$
|
|
5373
|
+
async function down$33(db) {
|
|
5289
5374
|
await db.schema.dropTable("restaurant_reservation_quote_checkouts").execute();
|
|
5290
5375
|
await sql`
|
|
5291
5376
|
DELETE FROM restaurant_refunds
|
|
@@ -5396,10 +5481,10 @@ async function assertForeignKeys$5(db) {
|
|
|
5396
5481
|
//#endregion
|
|
5397
5482
|
//#region src/database/migrations/091_restaurant_reservation_refunds.ts
|
|
5398
5483
|
var _091_restaurant_reservation_refunds_exports = /* @__PURE__ */ __exportAll({
|
|
5399
|
-
down: () => down$
|
|
5400
|
-
up: () => up$
|
|
5484
|
+
down: () => down$32,
|
|
5485
|
+
up: () => up$32
|
|
5401
5486
|
});
|
|
5402
|
-
async function up$
|
|
5487
|
+
async function up$32(db) {
|
|
5403
5488
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
5404
5489
|
try {
|
|
5405
5490
|
await sql`
|
|
@@ -5464,7 +5549,7 @@ async function up$31(db) {
|
|
|
5464
5549
|
}
|
|
5465
5550
|
await assertForeignKeys$4(db);
|
|
5466
5551
|
}
|
|
5467
|
-
async function down$
|
|
5552
|
+
async function down$32(db) {
|
|
5468
5553
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
5469
5554
|
try {
|
|
5470
5555
|
await sql`
|
|
@@ -5548,10 +5633,10 @@ async function assertForeignKeys$4(db) {
|
|
|
5548
5633
|
//#endregion
|
|
5549
5634
|
//#region src/database/migrations/092_restaurant_guest_profiles.ts
|
|
5550
5635
|
var _092_restaurant_guest_profiles_exports = /* @__PURE__ */ __exportAll({
|
|
5551
|
-
down: () => down$
|
|
5552
|
-
up: () => up$
|
|
5636
|
+
down: () => down$31,
|
|
5637
|
+
up: () => up$31
|
|
5553
5638
|
});
|
|
5554
|
-
async function up$
|
|
5639
|
+
async function up$31(db) {
|
|
5555
5640
|
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
5641
|
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
5642
|
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 +5709,7 @@ async function up$30(db) {
|
|
|
5624
5709
|
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
5710
|
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
5711
|
}
|
|
5627
|
-
async function down$
|
|
5712
|
+
async function down$31(db) {
|
|
5628
5713
|
await db.schema.dropTable("restaurant_guest_consents").execute();
|
|
5629
5714
|
await db.schema.dropTable("restaurant_guest_profile_reservations").execute();
|
|
5630
5715
|
await db.schema.dropTable("restaurant_guest_profile_requests").execute();
|
|
@@ -5634,24 +5719,24 @@ async function down$30(db) {
|
|
|
5634
5719
|
//#endregion
|
|
5635
5720
|
//#region src/database/migrations/093_restaurant_guest_profile_retention.ts
|
|
5636
5721
|
var _093_restaurant_guest_profile_retention_exports = /* @__PURE__ */ __exportAll({
|
|
5637
|
-
down: () => down$
|
|
5638
|
-
up: () => up$
|
|
5722
|
+
down: () => down$30,
|
|
5723
|
+
up: () => up$30
|
|
5639
5724
|
});
|
|
5640
|
-
async function up$
|
|
5725
|
+
async function up$30(db) {
|
|
5641
5726
|
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
5727
|
await db.schema.createIndex("idx_restaurant_guest_profile_retention_location_id").unique().on("restaurant_guest_profile_retention_settings").column("location_id").execute();
|
|
5643
5728
|
}
|
|
5644
|
-
async function down$
|
|
5729
|
+
async function down$30(db) {
|
|
5645
5730
|
await db.schema.dropTable("restaurant_guest_profile_retention_settings").execute();
|
|
5646
5731
|
}
|
|
5647
5732
|
|
|
5648
5733
|
//#endregion
|
|
5649
5734
|
//#region src/database/migrations/094_restaurant_guest_profile_sharing.ts
|
|
5650
5735
|
var _094_restaurant_guest_profile_sharing_exports = /* @__PURE__ */ __exportAll({
|
|
5651
|
-
down: () => down$
|
|
5652
|
-
up: () => up$
|
|
5736
|
+
down: () => down$29,
|
|
5737
|
+
up: () => up$29
|
|
5653
5738
|
});
|
|
5654
|
-
async function up$
|
|
5739
|
+
async function up$29(db) {
|
|
5655
5740
|
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
5741
|
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
5742
|
for (const [name, table, columns] of [
|
|
@@ -5697,7 +5782,7 @@ async function up$28(db) {
|
|
|
5697
5782
|
]
|
|
5698
5783
|
]) await db.schema.createIndex(name).on(table).columns([...columns]).execute();
|
|
5699
5784
|
}
|
|
5700
|
-
async function down$
|
|
5785
|
+
async function down$29(db) {
|
|
5701
5786
|
await db.schema.dropTable("restaurant_guest_profile_sharing_consents").execute();
|
|
5702
5787
|
await db.schema.dropTable("restaurant_related_location_pairs").execute();
|
|
5703
5788
|
}
|
|
@@ -5705,10 +5790,10 @@ async function down$28(db) {
|
|
|
5705
5790
|
//#endregion
|
|
5706
5791
|
//#region src/database/migrations/095_restaurant_priority_alert_notification_recovery.ts
|
|
5707
5792
|
var _095_restaurant_priority_alert_notification_recovery_exports = /* @__PURE__ */ __exportAll({
|
|
5708
|
-
down: () => down$
|
|
5709
|
-
up: () => up$
|
|
5793
|
+
down: () => down$28,
|
|
5794
|
+
up: () => up$28
|
|
5710
5795
|
});
|
|
5711
|
-
async function up$
|
|
5796
|
+
async function up$28(db) {
|
|
5712
5797
|
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
5798
|
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
5799
|
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 +5803,7 @@ async function up$27(db) {
|
|
|
5718
5803
|
"id"
|
|
5719
5804
|
]).execute();
|
|
5720
5805
|
}
|
|
5721
|
-
async function down$
|
|
5806
|
+
async function down$28(db) {
|
|
5722
5807
|
await db.schema.dropIndex("idx_restaurant_priority_alert_deliveries_failure_queue").execute();
|
|
5723
5808
|
await db.schema.alterTable("restaurant_priority_alert_deliveries").dropColumn("fallback_count").execute();
|
|
5724
5809
|
await db.schema.alterTable("restaurant_priority_alert_deliveries").dropColumn("channel_attempt_count").execute();
|
|
@@ -5731,8 +5816,8 @@ var _096_restaurant_reservation_notification_preferences_exports = /* @__PURE__
|
|
|
5731
5816
|
addRestaurantReservationNotificationPreferenceColumns: () => addRestaurantReservationNotificationPreferenceColumns,
|
|
5732
5817
|
addRestaurantReservationQuoteCheckoutNotificationPreferenceColumns: () => addRestaurantReservationQuoteCheckoutNotificationPreferenceColumns,
|
|
5733
5818
|
addRestaurantReservationRequestNotificationPreferenceColumns: () => addRestaurantReservationRequestNotificationPreferenceColumns,
|
|
5734
|
-
down: () => down$
|
|
5735
|
-
up: () => up$
|
|
5819
|
+
down: () => down$27,
|
|
5820
|
+
up: () => up$27
|
|
5736
5821
|
});
|
|
5737
5822
|
async function addRestaurantReservationNotificationPreferenceColumns(db) {
|
|
5738
5823
|
await addNotificationPreferenceColumns(db, "restaurant_reservations");
|
|
@@ -5743,12 +5828,12 @@ async function addRestaurantReservationRequestNotificationPreferenceColumns(db)
|
|
|
5743
5828
|
async function addRestaurantReservationQuoteCheckoutNotificationPreferenceColumns(db) {
|
|
5744
5829
|
await addNotificationPreferenceColumns(db, "restaurant_reservation_quote_checkouts");
|
|
5745
5830
|
}
|
|
5746
|
-
async function up$
|
|
5831
|
+
async function up$27(db) {
|
|
5747
5832
|
await addRestaurantReservationNotificationPreferenceColumns(db);
|
|
5748
5833
|
await addRestaurantReservationRequestNotificationPreferenceColumns(db);
|
|
5749
5834
|
await addRestaurantReservationQuoteCheckoutNotificationPreferenceColumns(db);
|
|
5750
5835
|
}
|
|
5751
|
-
async function down$
|
|
5836
|
+
async function down$27(db) {
|
|
5752
5837
|
await dropNotificationPreferenceColumns(db, "restaurant_reservation_quote_checkouts");
|
|
5753
5838
|
await dropNotificationPreferenceColumns(db, "restaurant_reservation_requests");
|
|
5754
5839
|
await dropNotificationPreferenceColumns(db, "restaurant_reservations");
|
|
@@ -5767,12 +5852,12 @@ async function dropNotificationPreferenceColumns(db, table) {
|
|
|
5767
5852
|
//#endregion
|
|
5768
5853
|
//#region src/database/migrations/097_restaurant_guest_notification_recovery.ts
|
|
5769
5854
|
var _097_restaurant_guest_notification_recovery_exports = /* @__PURE__ */ __exportAll({
|
|
5770
|
-
down: () => down$
|
|
5771
|
-
up: () => up$
|
|
5855
|
+
down: () => down$26,
|
|
5856
|
+
up: () => up$26
|
|
5772
5857
|
});
|
|
5773
5858
|
const REBUILT_TABLE = "_restaurant_outbox_deliveries_097";
|
|
5774
5859
|
const DOWN_TABLE$3 = "_restaurant_outbox_deliveries_097_down";
|
|
5775
|
-
async function up$
|
|
5860
|
+
async function up$26(db) {
|
|
5776
5861
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
5777
5862
|
try {
|
|
5778
5863
|
await createRecoverableDeliveryTable(db, REBUILT_TABLE);
|
|
@@ -5796,7 +5881,7 @@ async function up$25(db) {
|
|
|
5796
5881
|
}
|
|
5797
5882
|
await assertForeignKeys$3(db);
|
|
5798
5883
|
}
|
|
5799
|
-
async function down$
|
|
5884
|
+
async function down$26(db) {
|
|
5800
5885
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
5801
5886
|
try {
|
|
5802
5887
|
await createLegacyDeliveryTable(db, DOWN_TABLE$3);
|
|
@@ -5848,12 +5933,12 @@ async function assertForeignKeys$3(db) {
|
|
|
5848
5933
|
//#endregion
|
|
5849
5934
|
//#region src/database/migrations/098_restaurant_private_event_requests.ts
|
|
5850
5935
|
var _098_restaurant_private_event_requests_exports = /* @__PURE__ */ __exportAll({
|
|
5851
|
-
down: () => down$
|
|
5852
|
-
up: () => up$
|
|
5936
|
+
down: () => down$25,
|
|
5937
|
+
up: () => up$25
|
|
5853
5938
|
});
|
|
5854
5939
|
const UP_TABLE$2 = "_restaurant_reservation_requests_098";
|
|
5855
5940
|
const DOWN_TABLE$2 = "_restaurant_reservation_requests_098_down";
|
|
5856
|
-
async function up$
|
|
5941
|
+
async function up$25(db) {
|
|
5857
5942
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
5858
5943
|
try {
|
|
5859
5944
|
await createExperienceRequestTable(db);
|
|
@@ -5890,7 +5975,7 @@ async function up$24(db) {
|
|
|
5890
5975
|
}
|
|
5891
5976
|
await assertForeignKeys$2(db);
|
|
5892
5977
|
}
|
|
5893
|
-
async function down$
|
|
5978
|
+
async function down$25(db) {
|
|
5894
5979
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
5895
5980
|
try {
|
|
5896
5981
|
await createLegacyRequestTable(db);
|
|
@@ -6077,10 +6162,10 @@ async function assertForeignKeys$2(db) {
|
|
|
6077
6162
|
//#endregion
|
|
6078
6163
|
//#region src/database/migrations/099_restaurant_reservation_promotions.ts
|
|
6079
6164
|
var _099_restaurant_reservation_promotions_exports = /* @__PURE__ */ __exportAll({
|
|
6080
|
-
down: () => down$
|
|
6081
|
-
up: () => up$
|
|
6165
|
+
down: () => down$24,
|
|
6166
|
+
up: () => up$24
|
|
6082
6167
|
});
|
|
6083
|
-
async function up$
|
|
6168
|
+
async function up$24(db) {
|
|
6084
6169
|
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
6170
|
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
6171
|
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 +6227,7 @@ async function up$23(db) {
|
|
|
6142
6227
|
WHERE status IN ('held', 'attached')
|
|
6143
6228
|
`.execute(db);
|
|
6144
6229
|
}
|
|
6145
|
-
async function down$
|
|
6230
|
+
async function down$24(db) {
|
|
6146
6231
|
await db.schema.dropTable("restaurant_reservation_promotion_operations").execute();
|
|
6147
6232
|
await db.schema.dropTable("restaurant_reservation_promotion_allocations").execute();
|
|
6148
6233
|
await db.schema.dropTable("restaurant_reservation_promotions").execute();
|
|
@@ -6151,10 +6236,10 @@ async function down$23(db) {
|
|
|
6151
6236
|
//#endregion
|
|
6152
6237
|
//#region src/database/migrations/100_restaurant_reservation_gift_cards.ts
|
|
6153
6238
|
var _100_restaurant_reservation_gift_cards_exports = /* @__PURE__ */ __exportAll({
|
|
6154
|
-
down: () => down$
|
|
6155
|
-
up: () => up$
|
|
6239
|
+
down: () => down$23,
|
|
6240
|
+
up: () => up$23
|
|
6156
6241
|
});
|
|
6157
|
-
async function up$
|
|
6242
|
+
async function up$23(db) {
|
|
6158
6243
|
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
6244
|
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
6245
|
or (status = 'redeemed' and reservation_id is not null and redeemed_at is not null and released_at is null)
|
|
@@ -6233,7 +6318,7 @@ async function up$22(db) {
|
|
|
6233
6318
|
WHERE status = 'held'
|
|
6234
6319
|
`.execute(db);
|
|
6235
6320
|
}
|
|
6236
|
-
async function down$
|
|
6321
|
+
async function down$23(db) {
|
|
6237
6322
|
await db.schema.dropTable("restaurant_reservation_gift_card_operations").execute();
|
|
6238
6323
|
await db.schema.dropTable("restaurant_gift_card_ledger_entries").execute();
|
|
6239
6324
|
await db.schema.dropTable("restaurant_reservation_gift_card_allocations").execute();
|
|
@@ -6243,12 +6328,12 @@ async function down$22(db) {
|
|
|
6243
6328
|
//#endregion
|
|
6244
6329
|
//#region src/database/migrations/101_restaurant_reservation_request_payment_links.ts
|
|
6245
6330
|
var _101_restaurant_reservation_request_payment_links_exports = /* @__PURE__ */ __exportAll({
|
|
6246
|
-
down: () => down$
|
|
6247
|
-
up: () => up$
|
|
6331
|
+
down: () => down$22,
|
|
6332
|
+
up: () => up$22
|
|
6248
6333
|
});
|
|
6249
6334
|
const UP_TABLE$1 = "_restaurant_guest_access_101";
|
|
6250
6335
|
const DOWN_TABLE$1 = "_restaurant_guest_access_101_down";
|
|
6251
|
-
async function up$
|
|
6336
|
+
async function up$22(db) {
|
|
6252
6337
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
6253
6338
|
try {
|
|
6254
6339
|
await createGuestAccessTable$1(db, UP_TABLE$1, true);
|
|
@@ -6262,7 +6347,7 @@ async function up$21(db) {
|
|
|
6262
6347
|
}
|
|
6263
6348
|
await assertForeignKeys$1(db);
|
|
6264
6349
|
}
|
|
6265
|
-
async function down$
|
|
6350
|
+
async function down$22(db) {
|
|
6266
6351
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
6267
6352
|
try {
|
|
6268
6353
|
await db.schema.dropTable("restaurant_reservation_request_payment_link_deliveries").execute();
|
|
@@ -6325,12 +6410,12 @@ async function assertForeignKeys$1(db) {
|
|
|
6325
6410
|
//#endregion
|
|
6326
6411
|
//#region src/database/migrations/102_restaurant_reservation_offer_links.ts
|
|
6327
6412
|
var _102_restaurant_reservation_offer_links_exports = /* @__PURE__ */ __exportAll({
|
|
6328
|
-
down: () => down$
|
|
6329
|
-
up: () => up$
|
|
6413
|
+
down: () => down$21,
|
|
6414
|
+
up: () => up$21
|
|
6330
6415
|
});
|
|
6331
6416
|
const UP_TABLE = "_restaurant_guest_access_102";
|
|
6332
6417
|
const DOWN_TABLE = "_restaurant_guest_access_102_down";
|
|
6333
|
-
async function up$
|
|
6418
|
+
async function up$21(db) {
|
|
6334
6419
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
6335
6420
|
try {
|
|
6336
6421
|
await createGuestAccessTable(db, UP_TABLE, true);
|
|
@@ -6349,7 +6434,7 @@ async function up$20(db) {
|
|
|
6349
6434
|
}
|
|
6350
6435
|
await assertForeignKeys(db);
|
|
6351
6436
|
}
|
|
6352
|
-
async function down$
|
|
6437
|
+
async function down$21(db) {
|
|
6353
6438
|
await sql.raw("PRAGMA foreign_keys = OFF").execute(db);
|
|
6354
6439
|
try {
|
|
6355
6440
|
await db.schema.dropIndex("idx_restaurant_reservation_offers_location_created").execute();
|
|
@@ -6413,16 +6498,16 @@ async function assertForeignKeys(db) {
|
|
|
6413
6498
|
//#endregion
|
|
6414
6499
|
//#region src/database/migrations/103_restaurant_reservation_guest_details.ts
|
|
6415
6500
|
var _103_restaurant_reservation_guest_details_exports = /* @__PURE__ */ __exportAll({
|
|
6416
|
-
down: () => down$
|
|
6417
|
-
up: () => up$
|
|
6501
|
+
down: () => down$20,
|
|
6502
|
+
up: () => up$20
|
|
6418
6503
|
});
|
|
6419
|
-
async function up$
|
|
6504
|
+
async function up$20(db) {
|
|
6420
6505
|
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
6506
|
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
6507
|
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
6508
|
await createIndexes$3(db);
|
|
6424
6509
|
}
|
|
6425
|
-
async function down$
|
|
6510
|
+
async function down$20(db) {
|
|
6426
6511
|
await db.schema.dropTable("restaurant_reservation_guest_field_values").execute();
|
|
6427
6512
|
await db.schema.dropTable("restaurant_reservation_guest_fields").execute();
|
|
6428
6513
|
await db.schema.dropTable("restaurant_reservation_guest_settings").execute();
|
|
@@ -6460,10 +6545,10 @@ async function createIndexes$3(db) {
|
|
|
6460
6545
|
//#endregion
|
|
6461
6546
|
//#region src/database/migrations/104_restaurant_reservation_quote_guest_details.ts
|
|
6462
6547
|
var _104_restaurant_reservation_quote_guest_details_exports = /* @__PURE__ */ __exportAll({
|
|
6463
|
-
down: () => down$
|
|
6464
|
-
up: () => up$
|
|
6548
|
+
down: () => down$19,
|
|
6549
|
+
up: () => up$19
|
|
6465
6550
|
});
|
|
6466
|
-
async function up$
|
|
6551
|
+
async function up$19(db) {
|
|
6467
6552
|
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
6553
|
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
6554
|
for (const [name, table, columns] of [
|
|
@@ -6494,7 +6579,7 @@ async function up$18(db) {
|
|
|
6494
6579
|
]
|
|
6495
6580
|
]) await db.schema.createIndex(name).on(table).columns([...columns]).execute();
|
|
6496
6581
|
}
|
|
6497
|
-
async function down$
|
|
6582
|
+
async function down$19(db) {
|
|
6498
6583
|
await db.schema.dropTable("restaurant_reservation_quote_guest_field_values").execute();
|
|
6499
6584
|
await db.schema.dropTable("restaurant_reservation_quote_guest_contexts").execute();
|
|
6500
6585
|
}
|
|
@@ -6502,22 +6587,22 @@ async function down$18(db) {
|
|
|
6502
6587
|
//#endregion
|
|
6503
6588
|
//#region src/database/migrations/105_restaurant_reservation_language_settings.ts
|
|
6504
6589
|
var _105_restaurant_reservation_language_settings_exports = /* @__PURE__ */ __exportAll({
|
|
6505
|
-
down: () => down$
|
|
6506
|
-
up: () => up$
|
|
6590
|
+
down: () => down$18,
|
|
6591
|
+
up: () => up$18
|
|
6507
6592
|
});
|
|
6508
|
-
async function up$
|
|
6593
|
+
async function up$18(db) {
|
|
6509
6594
|
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
6595
|
await db.schema.createIndex("idx_restaurant_reservation_language_settings_location_id").on("restaurant_reservation_language_settings").column("location_id").execute();
|
|
6511
6596
|
}
|
|
6512
|
-
async function down$
|
|
6597
|
+
async function down$18(db) {
|
|
6513
6598
|
await db.schema.dropTable("restaurant_reservation_language_settings").execute();
|
|
6514
6599
|
}
|
|
6515
6600
|
|
|
6516
6601
|
//#endregion
|
|
6517
6602
|
//#region src/database/migrations/106_restaurant_reservation_analytics.ts
|
|
6518
6603
|
var _106_restaurant_reservation_analytics_exports = /* @__PURE__ */ __exportAll({
|
|
6519
|
-
down: () => down$
|
|
6520
|
-
up: () => up$
|
|
6604
|
+
down: () => down$17,
|
|
6605
|
+
up: () => up$17
|
|
6521
6606
|
});
|
|
6522
6607
|
const EVENT_TYPE_CHECK = sql`event_type IN (
|
|
6523
6608
|
'flow_viewed',
|
|
@@ -6531,7 +6616,7 @@ const EVENT_TYPE_CHECK = sql`event_type IN (
|
|
|
6531
6616
|
'priority_alert_subscribed',
|
|
6532
6617
|
'management_viewed'
|
|
6533
6618
|
)`;
|
|
6534
|
-
async function up$
|
|
6619
|
+
async function up$17(db) {
|
|
6535
6620
|
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
6621
|
await db.schema.createIndex("idx_restaurant_reservation_analytics_settings_location_id").on("restaurant_reservation_analytics_settings").column("location_id").execute();
|
|
6537
6622
|
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 +6624,7 @@ async function up$16(db) {
|
|
|
6539
6624
|
await db.schema.createIndex("idx_restaurant_reservation_analytics_events_location_occurred_at").on("restaurant_reservation_analytics_events").columns(["location_id", "occurred_at"]).execute();
|
|
6540
6625
|
await db.schema.createIndex("idx_restaurant_reservation_analytics_events_location_event_type").on("restaurant_reservation_analytics_events").columns(["location_id", "event_type"]).execute();
|
|
6541
6626
|
}
|
|
6542
|
-
async function down$
|
|
6627
|
+
async function down$17(db) {
|
|
6543
6628
|
await db.schema.dropTable("restaurant_reservation_analytics_events").execute();
|
|
6544
6629
|
await db.schema.dropTable("restaurant_reservation_analytics_settings").execute();
|
|
6545
6630
|
}
|
|
@@ -6547,24 +6632,24 @@ async function down$16(db) {
|
|
|
6547
6632
|
//#endregion
|
|
6548
6633
|
//#region src/database/migrations/107_payment_stripe_configuration.ts
|
|
6549
6634
|
var _107_payment_stripe_configuration_exports = /* @__PURE__ */ __exportAll({
|
|
6550
|
-
down: () => down$
|
|
6551
|
-
up: () => up$
|
|
6635
|
+
down: () => down$16,
|
|
6636
|
+
up: () => up$16
|
|
6552
6637
|
});
|
|
6553
|
-
async function up$
|
|
6554
|
-
async function down$
|
|
6638
|
+
async function up$16() {}
|
|
6639
|
+
async function down$16() {}
|
|
6555
6640
|
|
|
6556
6641
|
//#endregion
|
|
6557
6642
|
//#region src/database/migrations/108_venue_foundation.ts
|
|
6558
6643
|
var _108_venue_foundation_exports = /* @__PURE__ */ __exportAll({
|
|
6559
|
-
down: () => down$
|
|
6560
|
-
up: () => up$
|
|
6644
|
+
down: () => down$15,
|
|
6645
|
+
up: () => up$15
|
|
6561
6646
|
});
|
|
6562
6647
|
const RECORD_STATUS = sql`status in ('draft', 'active', 'archived')`;
|
|
6563
6648
|
const SPACE_STATUS = sql`status in ('draft', 'active', 'archived')`;
|
|
6564
6649
|
const BOOKING_MODE = sql`booking_mode in ('enquiry', 'request', 'instant')`;
|
|
6565
6650
|
const ORDER_STATUS = sql`status in ('enquired', 'requested', 'quoted', 'negotiating', 'accepted', 'payment_pending', 'confirmed', 'declined', 'withdrawn', 'expired', 'cancelled', 'completed')`;
|
|
6566
6651
|
const ORDER_HISTORY_TO_STATUS = sql`to_status in ('enquired', 'requested', 'quoted', 'negotiating', 'accepted', 'payment_pending', 'confirmed', 'declined', 'withdrawn', 'expired', 'cancelled', 'completed')`;
|
|
6567
|
-
async function up$
|
|
6652
|
+
async function up$15(db) {
|
|
6568
6653
|
await runStep("inventory tables", () => createInventoryTables(db));
|
|
6569
6654
|
await runStep("policy tables", () => createPolicyTables(db));
|
|
6570
6655
|
await runStep("order tables", () => createOrderTables(db));
|
|
@@ -6733,7 +6818,7 @@ async function createIndexes$2(db) {
|
|
|
6733
6818
|
throw new Error(`Index ${name} failed: ${message}`, { cause: error });
|
|
6734
6819
|
}
|
|
6735
6820
|
}
|
|
6736
|
-
async function down$
|
|
6821
|
+
async function down$15(db) {
|
|
6737
6822
|
await db.schema.dropTable("venue_availability_blocks").execute();
|
|
6738
6823
|
await db.schema.dropTable("venue_availability_rules").execute();
|
|
6739
6824
|
await db.schema.dropTable("venue_booking_holds").execute();
|
|
@@ -6751,10 +6836,10 @@ async function down$14(db) {
|
|
|
6751
6836
|
//#endregion
|
|
6752
6837
|
//#region src/database/migrations/109_venue_commercial_lifecycle.ts
|
|
6753
6838
|
var _109_venue_commercial_lifecycle_exports = /* @__PURE__ */ __exportAll({
|
|
6754
|
-
down: () => down$
|
|
6755
|
-
up: () => up$
|
|
6839
|
+
down: () => down$14,
|
|
6840
|
+
up: () => up$14
|
|
6756
6841
|
});
|
|
6757
|
-
async function up$
|
|
6842
|
+
async function up$14(db) {
|
|
6758
6843
|
await createCancellationTables(db);
|
|
6759
6844
|
await createQuoteTables(db);
|
|
6760
6845
|
await createPaymentTables(db);
|
|
@@ -6875,7 +6960,7 @@ async function createIndexes$1(db) {
|
|
|
6875
6960
|
]
|
|
6876
6961
|
]) await db.schema.createIndex(name).on(table).columns([...columns]).execute();
|
|
6877
6962
|
}
|
|
6878
|
-
async function down$
|
|
6963
|
+
async function down$14(db) {
|
|
6879
6964
|
await db.schema.dropTable("venue_payment_events").execute();
|
|
6880
6965
|
await db.schema.dropTable("venue_refunds").execute();
|
|
6881
6966
|
await db.schema.dropTable("venue_payments").execute();
|
|
@@ -6890,10 +6975,10 @@ async function down$13(db) {
|
|
|
6890
6975
|
//#endregion
|
|
6891
6976
|
//#region src/database/migrations/110_venue_communications_reviews.ts
|
|
6892
6977
|
var _110_venue_communications_reviews_exports = /* @__PURE__ */ __exportAll({
|
|
6893
|
-
down: () => down$
|
|
6894
|
-
up: () => up$
|
|
6978
|
+
down: () => down$13,
|
|
6979
|
+
up: () => up$13
|
|
6895
6980
|
});
|
|
6896
|
-
async function up$
|
|
6981
|
+
async function up$13(db) {
|
|
6897
6982
|
await createConversationTables(db);
|
|
6898
6983
|
await createNotificationTables(db);
|
|
6899
6984
|
await createReviewTables(db);
|
|
@@ -7012,7 +7097,7 @@ async function createIndexes(db) {
|
|
|
7012
7097
|
]
|
|
7013
7098
|
]) await db.schema.createIndex(name).on(table).columns([...columns]).execute();
|
|
7014
7099
|
}
|
|
7015
|
-
async function down$
|
|
7100
|
+
async function down$13(db) {
|
|
7016
7101
|
await db.schema.dropTable("venue_review_responses").execute();
|
|
7017
7102
|
await db.schema.dropTable("venue_reviews").execute();
|
|
7018
7103
|
await db.schema.dropTable("venue_review_invitations").execute();
|
|
@@ -7029,10 +7114,10 @@ async function down$12(db) {
|
|
|
7029
7114
|
var _111_content_release_grants_exports = /* @__PURE__ */ __exportAll({
|
|
7030
7115
|
createReleaseGrantsIndexes: () => createReleaseGrantsIndexes,
|
|
7031
7116
|
createReleaseGrantsTable: () => createReleaseGrantsTable,
|
|
7032
|
-
down: () => down$
|
|
7033
|
-
up: () => up$
|
|
7117
|
+
down: () => down$12,
|
|
7118
|
+
up: () => up$12
|
|
7034
7119
|
});
|
|
7035
|
-
async function up$
|
|
7120
|
+
async function up$12(db) {
|
|
7036
7121
|
await createReleaseGrantsTable(db);
|
|
7037
7122
|
await createReleaseGrantsIndexes(db);
|
|
7038
7123
|
}
|
|
@@ -7064,15 +7149,15 @@ async function createReleaseGrantsIndexes(db) {
|
|
|
7064
7149
|
WHERE status = 'active'
|
|
7065
7150
|
`.execute(db);
|
|
7066
7151
|
}
|
|
7067
|
-
async function down$
|
|
7152
|
+
async function down$12(db) {
|
|
7068
7153
|
await db.schema.dropTable("_dineway_content_release_grants").execute();
|
|
7069
7154
|
}
|
|
7070
7155
|
|
|
7071
7156
|
//#endregion
|
|
7072
7157
|
//#region src/database/migrations/114_assignment_overdue.ts
|
|
7073
7158
|
var _114_assignment_overdue_exports = /* @__PURE__ */ __exportAll({
|
|
7074
|
-
down: () => down$
|
|
7075
|
-
up: () => up$
|
|
7159
|
+
down: () => down$11,
|
|
7160
|
+
up: () => up$11
|
|
7076
7161
|
});
|
|
7077
7162
|
const ACTOR_TYPES = [
|
|
7078
7163
|
"user",
|
|
@@ -7096,7 +7181,7 @@ const PRIORITIES = [
|
|
|
7096
7181
|
"high",
|
|
7097
7182
|
"urgent"
|
|
7098
7183
|
];
|
|
7099
|
-
async function up$
|
|
7184
|
+
async function up$11(db) {
|
|
7100
7185
|
if (isSqlite(db)) {
|
|
7101
7186
|
await rebuildSqliteAssignments(db, true);
|
|
7102
7187
|
return;
|
|
@@ -7108,7 +7193,7 @@ async function up$10(db) {
|
|
|
7108
7193
|
"overdue"
|
|
7109
7194
|
]);
|
|
7110
7195
|
}
|
|
7111
|
-
async function down$
|
|
7196
|
+
async function down$11(db) {
|
|
7112
7197
|
if (isSqlite(db)) {
|
|
7113
7198
|
await rebuildSqliteAssignments(db, false);
|
|
7114
7199
|
return;
|
|
@@ -7233,28 +7318,28 @@ async function replacePostgresStatusConstraint(db, statuses) {
|
|
|
7233
7318
|
//#endregion
|
|
7234
7319
|
//#region src/database/migrations/115_integration_credentials.ts
|
|
7235
7320
|
var _115_integration_credentials_exports = /* @__PURE__ */ __exportAll({
|
|
7236
|
-
down: () => down$
|
|
7237
|
-
up: () => up$
|
|
7321
|
+
down: () => down$10,
|
|
7322
|
+
up: () => up$10
|
|
7238
7323
|
});
|
|
7239
|
-
async function up$
|
|
7324
|
+
async function up$10(db) {
|
|
7240
7325
|
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();
|
|
7241
7326
|
await db.schema.createIndex("idx_dineway_integration_credentials_updated_at").on("_dineway_integration_credentials").column("updated_at").execute();
|
|
7242
7327
|
}
|
|
7243
|
-
async function down$
|
|
7328
|
+
async function down$10(db) {
|
|
7244
7329
|
await db.schema.dropTable("_dineway_integration_credentials").execute();
|
|
7245
7330
|
}
|
|
7246
7331
|
|
|
7247
7332
|
//#endregion
|
|
7248
7333
|
//#region src/database/migrations/116_repair_fts_sync_triggers.ts
|
|
7249
7334
|
var _116_repair_fts_sync_triggers_exports = /* @__PURE__ */ __exportAll({
|
|
7250
|
-
down: () => down$
|
|
7251
|
-
up: () => up$
|
|
7335
|
+
down: () => down$9,
|
|
7336
|
+
up: () => up$9
|
|
7252
7337
|
});
|
|
7253
7338
|
/**
|
|
7254
7339
|
* Rebuild enabled FTS5 indexes so existing sites receive the corrected
|
|
7255
7340
|
* external-content update and delete triggers before their next content write.
|
|
7256
7341
|
*/
|
|
7257
|
-
async function up$
|
|
7342
|
+
async function up$9(db) {
|
|
7258
7343
|
if (!isSqlite(db)) return;
|
|
7259
7344
|
const collections = await sql`
|
|
7260
7345
|
SELECT id, slug, search_config
|
|
@@ -7342,19 +7427,19 @@ function isSearchEnabled(searchConfig) {
|
|
|
7342
7427
|
return false;
|
|
7343
7428
|
}
|
|
7344
7429
|
}
|
|
7345
|
-
async function down$
|
|
7430
|
+
async function down$9(_db) {}
|
|
7346
7431
|
|
|
7347
7432
|
//#endregion
|
|
7348
7433
|
//#region src/database/migrations/117_content_taxonomy_covering_index.ts
|
|
7349
7434
|
var _117_content_taxonomy_covering_index_exports = /* @__PURE__ */ __exportAll({
|
|
7350
|
-
down: () => down$
|
|
7351
|
-
up: () => up$
|
|
7435
|
+
down: () => down$8,
|
|
7436
|
+
up: () => up$8
|
|
7352
7437
|
});
|
|
7353
7438
|
/**
|
|
7354
7439
|
* Replace the single-column taxonomy reverse index with a covering index for
|
|
7355
7440
|
* term-driven collection queries.
|
|
7356
7441
|
*/
|
|
7357
|
-
async function up$
|
|
7442
|
+
async function up$8(db) {
|
|
7358
7443
|
await db.schema.createIndex("idx_content_taxonomies_term_collection_entry").ifNotExists().on("content_taxonomies").columns([
|
|
7359
7444
|
"taxonomy_id",
|
|
7360
7445
|
"collection",
|
|
@@ -7362,7 +7447,7 @@ async function up$7(db) {
|
|
|
7362
7447
|
]).execute();
|
|
7363
7448
|
await db.schema.dropIndex("idx_content_taxonomies_term").ifExists().execute();
|
|
7364
7449
|
}
|
|
7365
|
-
async function down$
|
|
7450
|
+
async function down$8(db) {
|
|
7366
7451
|
await db.schema.createIndex("idx_content_taxonomies_term").ifNotExists().on("content_taxonomies").column("taxonomy_id").execute();
|
|
7367
7452
|
await db.schema.dropIndex("idx_content_taxonomies_term_collection_entry").ifExists().execute();
|
|
7368
7453
|
}
|
|
@@ -7370,14 +7455,14 @@ async function down$7(db) {
|
|
|
7370
7455
|
//#endregion
|
|
7371
7456
|
//#region src/database/migrations/118_collection_url_field.ts
|
|
7372
7457
|
var _118_collection_url_field_exports = /* @__PURE__ */ __exportAll({
|
|
7373
|
-
down: () => down$
|
|
7374
|
-
up: () => up$
|
|
7458
|
+
down: () => down$7,
|
|
7459
|
+
up: () => up$7
|
|
7375
7460
|
});
|
|
7376
|
-
async function up$
|
|
7461
|
+
async function up$7(db) {
|
|
7377
7462
|
await db.schema.alterTable("_dineway_collections").addColumn("url_field", "text").execute();
|
|
7378
7463
|
await updateIndexes(db, true);
|
|
7379
7464
|
}
|
|
7380
|
-
async function down$
|
|
7465
|
+
async function down$7(db) {
|
|
7381
7466
|
await updateIndexes(db, false);
|
|
7382
7467
|
await db.schema.alterTable("_dineway_collections").dropColumn("url_field").execute();
|
|
7383
7468
|
}
|
|
@@ -7394,41 +7479,41 @@ async function updateIndexes(db, create) {
|
|
|
7394
7479
|
//#endregion
|
|
7395
7480
|
//#region src/database/migrations/119_public_discovery_rules.ts
|
|
7396
7481
|
var _119_public_discovery_rules_exports = /* @__PURE__ */ __exportAll({
|
|
7397
|
-
down: () => down$
|
|
7398
|
-
up: () => up$
|
|
7482
|
+
down: () => down$6,
|
|
7483
|
+
up: () => up$6
|
|
7399
7484
|
});
|
|
7400
|
-
async function up$
|
|
7485
|
+
async function up$6(db) {
|
|
7401
7486
|
await db.schema.alterTable("_dineway_collections").addColumn("public_discovery", "text").execute();
|
|
7402
7487
|
}
|
|
7403
|
-
async function down$
|
|
7488
|
+
async function down$6(db) {
|
|
7404
7489
|
await db.schema.alterTable("_dineway_collections").dropColumn("public_discovery").execute();
|
|
7405
7490
|
}
|
|
7406
7491
|
|
|
7407
7492
|
//#endregion
|
|
7408
7493
|
//#region src/database/migrations/120_payment_subscriptions.ts
|
|
7409
7494
|
var _120_payment_subscriptions_exports = /* @__PURE__ */ __exportAll({
|
|
7410
|
-
down: () => down$
|
|
7411
|
-
up: () => up$
|
|
7495
|
+
down: () => down$5,
|
|
7496
|
+
up: () => up$5
|
|
7412
7497
|
});
|
|
7413
|
-
async function up$
|
|
7414
|
-
async function down$
|
|
7498
|
+
async function up$5() {}
|
|
7499
|
+
async function down$5() {}
|
|
7415
7500
|
|
|
7416
7501
|
//#endregion
|
|
7417
7502
|
//#region src/database/migrations/121_payment_purchases.ts
|
|
7418
7503
|
var _121_payment_purchases_exports = /* @__PURE__ */ __exportAll({
|
|
7419
|
-
down: () => down$
|
|
7420
|
-
up: () => up$
|
|
7504
|
+
down: () => down$4,
|
|
7505
|
+
up: () => up$4
|
|
7421
7506
|
});
|
|
7422
|
-
async function up$
|
|
7423
|
-
async function down$
|
|
7507
|
+
async function up$4() {}
|
|
7508
|
+
async function down$4() {}
|
|
7424
7509
|
|
|
7425
7510
|
//#endregion
|
|
7426
7511
|
//#region src/database/migrations/122_integration_runs.ts
|
|
7427
7512
|
var _122_integration_runs_exports = /* @__PURE__ */ __exportAll({
|
|
7428
|
-
down: () => down$
|
|
7429
|
-
up: () => up$
|
|
7513
|
+
down: () => down$3,
|
|
7514
|
+
up: () => up$3
|
|
7430
7515
|
});
|
|
7431
|
-
async function up$
|
|
7516
|
+
async function up$3(db) {
|
|
7432
7517
|
await db.schema.createTable("_dineway_integration_runs").addColumn("id", "text", (c) => c.primaryKey()).addColumn("actor_id", "text", (c) => c.notNull()).addColumn("idempotency_key", "text").addColumn("request_hash", "text", (c) => c.notNull()).addColumn("request_json", "text", (c) => c.notNull()).addColumn("run_json", "text", (c) => c.notNull()).addColumn("state", "text", (c) => c.notNull()).addColumn("upstream_id", "text").addColumn("credential_fingerprint", "text", (c) => c.notNull()).addColumn("created_at", "text", (c) => c.notNull()).addColumn("updated_at", "text", (c) => c.notNull()).execute();
|
|
7433
7518
|
await db.schema.createIndex("idx_dineway_integration_runs_actor_key").on("_dineway_integration_runs").columns(["actor_id", "idempotency_key"]).unique().execute();
|
|
7434
7519
|
await db.schema.createIndex("idx_dineway_integration_runs_actor_created").on("_dineway_integration_runs").columns([
|
|
@@ -7438,24 +7523,24 @@ async function up$2(db) {
|
|
|
7438
7523
|
]).execute();
|
|
7439
7524
|
await db.schema.createIndex("idx_dineway_integration_runs_state_updated").on("_dineway_integration_runs").columns(["state", "updated_at"]).execute();
|
|
7440
7525
|
}
|
|
7441
|
-
async function down$
|
|
7526
|
+
async function down$3(db) {
|
|
7442
7527
|
await db.schema.dropTable("_dineway_integration_runs").execute();
|
|
7443
7528
|
}
|
|
7444
7529
|
|
|
7445
7530
|
//#endregion
|
|
7446
7531
|
//#region src/database/migrations/123_review_automation.ts
|
|
7447
7532
|
var _123_review_automation_exports = /* @__PURE__ */ __exportAll({
|
|
7448
|
-
down: () => down$
|
|
7449
|
-
up: () => up$
|
|
7533
|
+
down: () => down$2,
|
|
7534
|
+
up: () => up$2
|
|
7450
7535
|
});
|
|
7451
|
-
async function up$
|
|
7536
|
+
async function up$2(db) {
|
|
7452
7537
|
await db.schema.alterTable("_dineway_review_requests").addColumn("revoked_at", "text").execute();
|
|
7453
7538
|
await db.schema.createTable("_dineway_review_jobs").addColumn("review_id", "text", (c) => c.primaryKey().references("_dineway_review_requests.id").onDelete("cascade")).addColumn("target_key", "text", (c) => c.notNull().unique()).addColumn("content_hash", "text", (c) => c.notNull()).addColumn("state", "text", (c) => c.notNull()).addColumn("release_state", "text", (c) => c.notNull()).addColumn("evidence_json", "text").addColumn("reason", "text").addColumn("release_reason", "text").addColumn("scheduled_at", "text").addColumn("created_at", "text", (c) => c.notNull()).addColumn("updated_at", "text", (c) => c.notNull()).execute();
|
|
7454
7539
|
await db.schema.createIndex("idx_dineway_review_jobs_state_updated").on("_dineway_review_jobs").columns(["state", "updated_at"]).execute();
|
|
7455
7540
|
await db.schema.createIndex("idx_dineway_review_jobs_release_updated").on("_dineway_review_jobs").columns(["release_state", "updated_at"]).execute();
|
|
7456
7541
|
await db.schema.createIndex("idx_dineway_review_jobs_content_hash").on("_dineway_review_jobs").column("content_hash").execute();
|
|
7457
7542
|
}
|
|
7458
|
-
async function down$
|
|
7543
|
+
async function down$2(db) {
|
|
7459
7544
|
await db.schema.dropTable("_dineway_review_jobs").execute();
|
|
7460
7545
|
await db.schema.alterTable("_dineway_review_requests").dropColumn("revoked_at").execute();
|
|
7461
7546
|
}
|
|
@@ -7463,8 +7548,8 @@ async function down$1(db) {
|
|
|
7463
7548
|
//#endregion
|
|
7464
7549
|
//#region src/database/migrations/124_review_release_authority.ts
|
|
7465
7550
|
var _124_review_release_authority_exports = /* @__PURE__ */ __exportAll({
|
|
7466
|
-
down: () => down,
|
|
7467
|
-
up: () => up
|
|
7551
|
+
down: () => down$1,
|
|
7552
|
+
up: () => up$1
|
|
7468
7553
|
});
|
|
7469
7554
|
async function replaceTable(db, automated) {
|
|
7470
7555
|
await createReleaseGrantsTable(db, automated, "_dineway_content_release_grants_next");
|
|
@@ -7473,15 +7558,28 @@ async function replaceTable(db, automated) {
|
|
|
7473
7558
|
await db.schema.alterTable("_dineway_content_release_grants_next").renameTo("_dineway_content_release_grants").execute();
|
|
7474
7559
|
await createReleaseGrantsIndexes(db);
|
|
7475
7560
|
}
|
|
7476
|
-
async function up(db) {
|
|
7561
|
+
async function up$1(db) {
|
|
7477
7562
|
await replaceTable(db, true);
|
|
7478
7563
|
}
|
|
7479
|
-
async function down(db) {
|
|
7564
|
+
async function down$1(db) {
|
|
7480
7565
|
const result = await sql`SELECT count(*) AS count FROM _dineway_content_release_grants WHERE authorization_method = 'review_automation'`.execute(db);
|
|
7481
7566
|
if (Number(result.rows[0]?.count)) throw new Error("Automated release history must be retained; this migration cannot be rolled back after automated publication.");
|
|
7482
7567
|
await replaceTable(db, false);
|
|
7483
7568
|
}
|
|
7484
7569
|
|
|
7570
|
+
//#endregion
|
|
7571
|
+
//#region src/database/migrations/125_cron_task_leases.ts
|
|
7572
|
+
var _125_cron_task_leases_exports = /* @__PURE__ */ __exportAll({
|
|
7573
|
+
down: () => down,
|
|
7574
|
+
up: () => up
|
|
7575
|
+
});
|
|
7576
|
+
async function up(db) {
|
|
7577
|
+
await db.schema.alterTable("_dineway_cron_tasks").addColumn("lease_token", "text").execute();
|
|
7578
|
+
}
|
|
7579
|
+
async function down(db) {
|
|
7580
|
+
await db.schema.alterTable("_dineway_cron_tasks").dropColumn("lease_token").execute();
|
|
7581
|
+
}
|
|
7582
|
+
|
|
7485
7583
|
//#endregion
|
|
7486
7584
|
//#region src/database/migrations/runner.ts
|
|
7487
7585
|
const MIGRATIONS = Object.freeze({
|
|
@@ -7605,7 +7703,8 @@ const MIGRATIONS = Object.freeze({
|
|
|
7605
7703
|
"121_payment_purchases": _121_payment_purchases_exports,
|
|
7606
7704
|
"122_integration_runs": _122_integration_runs_exports,
|
|
7607
7705
|
"123_review_automation": _123_review_automation_exports,
|
|
7608
|
-
"124_review_release_authority": _124_review_release_authority_exports
|
|
7706
|
+
"124_review_release_authority": _124_review_release_authority_exports,
|
|
7707
|
+
"125_cron_task_leases": _125_cron_task_leases_exports
|
|
7609
7708
|
});
|
|
7610
7709
|
const MIGRATION_NAMES = Object.freeze(Object.keys(MIGRATIONS).toSorted());
|
|
7611
7710
|
/** Total number of registered migrations. Exported for use in tests. */
|
|
@@ -7656,6 +7755,10 @@ async function getMigrationStatus(db) {
|
|
|
7656
7755
|
* Run all pending migrations
|
|
7657
7756
|
*/
|
|
7658
7757
|
async function runMigrations(db) {
|
|
7758
|
+
if (d1Database(db)) {
|
|
7759
|
+
await assertD1Migrations(db, MIGRATION_TABLE, MIGRATION_NAMES);
|
|
7760
|
+
return { applied: [] };
|
|
7761
|
+
}
|
|
7659
7762
|
const { error, results } = await new Migrator({
|
|
7660
7763
|
db,
|
|
7661
7764
|
provider: new StaticMigrationProvider(),
|
|
@@ -7691,4 +7794,4 @@ async function rollbackMigration(db) {
|
|
|
7691
7794
|
}
|
|
7692
7795
|
|
|
7693
7796
|
//#endregion
|
|
7694
|
-
export {
|
|
7797
|
+
export { runMigrations as a, __exportAll as c, rollbackMigration as i, getMigrationFingerprint as n, assertD1Migrations as o, getMigrationStatus as r, migrateD1 as s, MIGRATION_NAMES as t };
|