dineway 0.1.15 → 0.1.17
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/README.md +22 -0
- package/dist/{activity-events-B4wp7CrU.mjs → activity-events-DbqJBNaY.mjs} +1 -1
- package/dist/{allowed-origins-C1AKK9AT.mjs → allowed-origins-D85wzUp6.mjs} +1 -1
- package/dist/api/route-utils.d.mts +10 -10
- package/dist/api/route-utils.mjs +15 -15
- package/dist/api/schemas/index.d.mts +2 -2
- package/dist/api/schemas/index.mjs +4 -4
- package/dist/{api-DX6X_a82.mjs → api-CgxdfUg4.mjs} +96 -17
- package/dist/{api-tokens-D7UjLbdt.mjs → api-tokens-CMmUPFae.mjs} +1 -1
- package/dist/{apply-Bm5QgdrE.mjs → apply-CGVHi2r7.mjs} +165 -85
- package/dist/astro/index.d.mts +11 -11
- package/dist/astro/index.mjs +3 -3
- package/dist/astro/middleware/auth.d.mts +10 -10
- package/dist/astro/middleware/auth.mjs +5 -5
- package/dist/astro/middleware/redirect.mjs +6 -6
- package/dist/astro/middleware/request-context.mjs +4 -4
- package/dist/astro/middleware/setup.mjs +1 -1
- package/dist/astro/middleware.mjs +119 -77
- package/dist/astro/routes/api/admin/allowed-domains/_domain_.mjs +5 -5
- package/dist/astro/routes/api/admin/allowed-domains/index.mjs +5 -5
- package/dist/astro/routes/api/admin/api-tokens/_id_.mjs +4 -4
- package/dist/astro/routes/api/admin/api-tokens/index.mjs +6 -6
- package/dist/astro/routes/api/admin/briefing.mjs +19 -19
- package/dist/astro/routes/api/admin/bylines/_id_/index.mjs +12 -12
- package/dist/astro/routes/api/admin/bylines/index.mjs +12 -12
- package/dist/astro/routes/api/admin/comments/_id_/status.mjs +13 -13
- package/dist/astro/routes/api/admin/comments/_id_.mjs +6 -6
- package/dist/astro/routes/api/admin/comments/bulk.mjs +10 -10
- package/dist/astro/routes/api/admin/comments/counts.mjs +6 -6
- package/dist/astro/routes/api/admin/comments/index.mjs +10 -10
- package/dist/astro/routes/api/admin/context/_id_/history.mjs +26 -26
- package/dist/astro/routes/api/admin/context/_id_/index.mjs +26 -26
- package/dist/astro/routes/api/admin/context/_id_/review.mjs +30 -30
- package/dist/astro/routes/api/admin/context/_id_/supersede.mjs +30 -30
- package/dist/astro/routes/api/admin/context/diff.mjs +29 -29
- package/dist/astro/routes/api/admin/context/index.mjs +30 -30
- package/dist/astro/routes/api/admin/context/stale.mjs +29 -29
- package/dist/astro/routes/api/admin/hitl-requests/_id_/index.mjs +26 -26
- package/dist/astro/routes/api/admin/hitl-requests/_id_/resolve.mjs +29 -29
- package/dist/astro/routes/api/admin/hitl-requests/index.mjs +29 -29
- package/dist/astro/routes/api/admin/hooks/exclusive/_hookName_.mjs +27 -27
- package/dist/astro/routes/api/admin/hooks/exclusive/index.mjs +3 -3
- package/dist/astro/routes/api/admin/oauth-clients/_id_.mjs +6 -6
- package/dist/astro/routes/api/admin/oauth-clients/index.mjs +6 -6
- package/dist/astro/routes/api/admin/plugins/_id_/disable.mjs +47 -47
- package/dist/astro/routes/api/admin/plugins/_id_/enable.mjs +47 -47
- package/dist/astro/routes/api/admin/plugins/_id_/index.mjs +40 -40
- package/dist/astro/routes/api/admin/plugins/_id_/uninstall.mjs +46 -46
- package/dist/astro/routes/api/admin/plugins/_id_/update.mjs +46 -46
- package/dist/astro/routes/api/admin/plugins/index.mjs +40 -40
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/icon.mjs +2 -2
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/index.mjs +40 -40
- package/dist/astro/routes/api/admin/plugins/marketplace/_id_/install.mjs +46 -46
- package/dist/astro/routes/api/admin/plugins/marketplace/index.mjs +40 -40
- package/dist/astro/routes/api/admin/plugins/updates.mjs +40 -40
- package/dist/astro/routes/api/admin/review-requests/_id_/index.mjs +6 -6
- package/dist/astro/routes/api/admin/review-requests/_id_/resolve.mjs +29 -29
- package/dist/astro/routes/api/admin/review-requests/index.mjs +10 -10
- package/dist/astro/routes/api/admin/themes/marketplace/_id_/index.mjs +40 -40
- package/dist/astro/routes/api/admin/themes/marketplace/_id_/thumbnail.mjs +2 -2
- package/dist/astro/routes/api/admin/themes/marketplace/index.mjs +40 -40
- package/dist/astro/routes/api/admin/users/_id_/disable.mjs +2 -2
- package/dist/astro/routes/api/admin/users/_id_/enable.mjs +1 -1
- package/dist/astro/routes/api/admin/users/_id_/index.mjs +6 -6
- package/dist/astro/routes/api/admin/users/_id_/send-recovery.mjs +3 -3
- package/dist/astro/routes/api/admin/users/index.mjs +5 -5
- package/dist/astro/routes/api/auth/dev-bypass.mjs +5 -5
- package/dist/astro/routes/api/auth/invite/accept.mjs +1 -1
- package/dist/astro/routes/api/auth/invite/complete.mjs +10 -10
- package/dist/astro/routes/api/auth/invite/index.mjs +7 -7
- package/dist/astro/routes/api/auth/invite/register-options.mjs +9 -9
- package/dist/astro/routes/api/auth/logout.mjs +2 -2
- package/dist/astro/routes/api/auth/magic-link/send.mjs +9 -9
- package/dist/astro/routes/api/auth/magic-link/verify.mjs +2 -2
- package/dist/astro/routes/api/auth/me.mjs +5 -5
- package/dist/astro/routes/api/auth/mode.mjs +1 -1
- package/dist/astro/routes/api/auth/oauth/_provider_/callback.mjs +2 -2
- package/dist/astro/routes/api/auth/oauth/_provider_.mjs +2 -2
- package/dist/astro/routes/api/auth/passkey/_id_.mjs +5 -5
- package/dist/astro/routes/api/auth/passkey/index.mjs +1 -1
- package/dist/astro/routes/api/auth/passkey/options.mjs +11 -11
- package/dist/astro/routes/api/auth/passkey/register/options.mjs +9 -9
- package/dist/astro/routes/api/auth/passkey/register/verify.mjs +10 -10
- package/dist/astro/routes/api/auth/passkey/verify.mjs +10 -10
- package/dist/astro/routes/api/auth/signup/complete.mjs +10 -10
- package/dist/astro/routes/api/auth/signup/request.mjs +9 -9
- package/dist/astro/routes/api/auth/signup/verify.mjs +1 -1
- package/dist/astro/routes/api/comments/_collection_/_contentId_/index.mjs +14 -14
- package/dist/astro/routes/api/content/_collection_/_id_/compare.mjs +2 -2
- package/dist/astro/routes/api/content/_collection_/_id_/discard-draft.mjs +6 -6
- package/dist/astro/routes/api/content/_collection_/_id_/duplicate.mjs +6 -6
- package/dist/astro/routes/api/content/_collection_/_id_/permanent.mjs +7 -7
- package/dist/astro/routes/api/content/_collection_/_id_/preview-url.mjs +12 -12
- package/dist/astro/routes/api/content/_collection_/_id_/publish.mjs +28 -28
- package/dist/astro/routes/api/content/_collection_/_id_/restore.mjs +6 -6
- package/dist/astro/routes/api/content/_collection_/_id_/revisions.mjs +2 -2
- package/dist/astro/routes/api/content/_collection_/_id_/schedule.mjs +10 -10
- package/dist/astro/routes/api/content/_collection_/_id_/terms/_taxonomy_.mjs +13 -13
- package/dist/astro/routes/api/content/_collection_/_id_/translations.mjs +2 -2
- package/dist/astro/routes/api/content/_collection_/_id_/unpublish.mjs +6 -6
- package/dist/astro/routes/api/content/_collection_/_id_.mjs +10 -10
- package/dist/astro/routes/api/content/_collection_/index.mjs +10 -10
- package/dist/astro/routes/api/content/_collection_/trash.mjs +6 -6
- package/dist/astro/routes/api/dashboard.mjs +9 -9
- 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 +10 -10
- package/dist/astro/routes/api/import/wordpress/analyze.mjs +3 -3
- package/dist/astro/routes/api/import/wordpress/execute.mjs +29 -29
- package/dist/astro/routes/api/import/wordpress/media.mjs +7 -7
- package/dist/astro/routes/api/import/wordpress/prepare.mjs +33 -33
- package/dist/astro/routes/api/import/wordpress/rewrite-url-helpers.d.mts +48 -0
- package/dist/astro/routes/api/import/wordpress/rewrite-url-helpers.mjs +124 -0
- package/dist/astro/routes/api/import/wordpress/rewrite-urls.mjs +32 -145
- package/dist/astro/routes/api/import/wordpress-plugin/analyze.d.mts +1 -1
- package/dist/astro/routes/api/import/wordpress-plugin/analyze.mjs +10 -10
- package/dist/astro/routes/api/import/wordpress-plugin/callback.mjs +1 -1
- package/dist/astro/routes/api/import/wordpress-plugin/execute.d.mts +1 -1
- package/dist/astro/routes/api/import/wordpress-plugin/execute.mjs +33 -33
- package/dist/astro/routes/api/manifest.mjs +4 -4
- package/dist/astro/routes/api/mcp.mjs +277 -91
- package/dist/astro/routes/api/media/_id_/confirm.mjs +6 -6
- package/dist/astro/routes/api/media/_id_.mjs +6 -6
- 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 +11 -13
- package/dist/astro/routes/api/media.mjs +18 -18
- package/dist/astro/routes/api/menus/_name_/items.mjs +45 -36
- package/dist/astro/routes/api/menus/_name_/reorder.mjs +34 -31
- package/dist/astro/routes/api/menus/_name_/translations.d.mts +8 -0
- package/dist/astro/routes/api/menus/_name_/translations.mjs +111 -0
- package/dist/astro/routes/api/menus/_name_.mjs +47 -36
- package/dist/astro/routes/api/menus/index.mjs +34 -32
- package/dist/astro/routes/api/oauth/authorize.mjs +7 -7
- package/dist/astro/routes/api/oauth/device/authorize.mjs +6 -6
- package/dist/astro/routes/api/oauth/device/code.mjs +9 -9
- package/dist/astro/routes/api/oauth/device/token.mjs +8 -8
- package/dist/astro/routes/api/oauth/register.mjs +4 -4
- package/dist/astro/routes/api/oauth/token/refresh.mjs +6 -6
- package/dist/astro/routes/api/oauth/token/revoke.mjs +6 -6
- package/dist/astro/routes/api/oauth/token.mjs +6 -6
- package/dist/astro/routes/api/openapi.json.mjs +3 -3
- package/dist/astro/routes/api/plugins/_pluginId_/_...path_.mjs +3 -3
- package/dist/astro/routes/api/redirects/404s/index.mjs +12 -12
- package/dist/astro/routes/api/redirects/404s/summary.mjs +12 -12
- package/dist/astro/routes/api/redirects/_id_.mjs +31 -31
- package/dist/astro/routes/api/redirects/index.mjs +31 -31
- 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 +41 -41
- package/dist/astro/routes/api/schema/collections/_slug_/fields/index.mjs +41 -41
- package/dist/astro/routes/api/schema/collections/_slug_/fields/reorder.mjs +41 -41
- package/dist/astro/routes/api/schema/collections/_slug_/index.mjs +41 -41
- package/dist/astro/routes/api/schema/collections/index.mjs +41 -41
- package/dist/astro/routes/api/schema/index.mjs +6 -6
- package/dist/astro/routes/api/schema/orphans/_slug_.mjs +40 -40
- package/dist/astro/routes/api/schema/orphans/index.mjs +40 -40
- package/dist/astro/routes/api/search/enable.mjs +12 -12
- package/dist/astro/routes/api/search/index.mjs +11 -11
- package/dist/astro/routes/api/search/rebuild.mjs +12 -12
- package/dist/astro/routes/api/search/stats.mjs +8 -8
- package/dist/astro/routes/api/search/suggest.mjs +11 -11
- package/dist/astro/routes/api/sections/_slug_.mjs +30 -30
- package/dist/astro/routes/api/sections/index.mjs +30 -30
- package/dist/astro/routes/api/settings/email.mjs +4 -4
- package/dist/astro/routes/api/settings.mjs +30 -30
- package/dist/astro/routes/api/setup/admin-verify.mjs +12 -12
- package/dist/astro/routes/api/setup/admin.mjs +10 -10
- package/dist/astro/routes/api/setup/dev-bypass.mjs +25 -25
- package/dist/astro/routes/api/setup/dev-reset.mjs +2 -2
- package/dist/astro/routes/api/setup/index.mjs +26 -26
- package/dist/astro/routes/api/setup/status.mjs +3 -3
- package/dist/astro/routes/api/snapshot.mjs +7 -7
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.d.mts +8 -0
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_/translations.mjs +131 -0
- package/dist/astro/routes/api/taxonomies/_name_/terms/_slug_.mjs +49 -41
- package/dist/astro/routes/api/taxonomies/_name_/terms/index.mjs +36 -34
- package/dist/astro/routes/api/taxonomies/index.mjs +36 -34
- package/dist/astro/routes/api/themes/preview.mjs +6 -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 +29 -29
- package/dist/astro/routes/api/widget-areas/_name_/widgets/_id_.mjs +30 -30
- package/dist/astro/routes/api/widget-areas/_name_/widgets.mjs +30 -30
- package/dist/astro/routes/api/widget-areas/_name_.mjs +28 -28
- package/dist/astro/routes/api/widget-areas/index.mjs +30 -30
- package/dist/astro/routes/api/widget-components.mjs +2 -2
- package/dist/astro/routes/robots.txt.mjs +9 -9
- package/dist/astro/routes/sitemap-_collection_.xml.mjs +9 -9
- package/dist/astro/routes/sitemap.xml.mjs +10 -10
- package/dist/astro/types.d.mts +16 -14
- package/dist/auth/providers/github.d.mts +1 -1
- package/dist/auth/providers/google.d.mts +1 -1
- package/dist/{auth-control-guard-DOZ3UCsP.mjs → auth-control-guard--r6LlNkX.mjs} +1 -1
- package/dist/{authorize-BAdbMCwC.mjs → authorize-wQDmXQJ1.mjs} +1 -1
- package/dist/{briefing-MVYe_Uyf.mjs → briefing-4k6R0KAr.mjs} +7 -7
- package/dist/{briefing-rty4O-wa.mjs → briefing-DM7e2yd3.mjs} +1 -1
- package/dist/{byline-naZxOPSa.mjs → byline-BxAf79s1.mjs} +4 -4
- package/dist/{bylines-DCvz5gtm.d.mts → bylines--KurdDQK.d.mts} +84 -22
- package/dist/{bylines-C4LIBOOO.mjs → bylines-DhCnhR70.mjs} +3 -3
- package/dist/{cache-DEbQ13c9.mjs → cache-inQvbrP5.mjs} +1 -1
- package/dist/{chunks-D_jVet6z.mjs → chunks-vkrCT4Ta.mjs} +7 -1
- package/dist/cli/index.mjs +337 -102
- package/dist/client/external-auth-headers.d.mts +1 -1
- package/dist/client/index.d.mts +1 -1
- package/dist/client/index.mjs +1 -1
- package/dist/{comment-DFO-gWDH.mjs → comment-BmJXz3lc.mjs} +1 -1
- package/dist/{comments--BsZ9pqA.mjs → comments-BW1qFiTa.mjs} +1 -1
- package/dist/{content-CyLkb-qH.mjs → content-DvpMad_N.mjs} +4 -3
- package/dist/{context-DNfcm853.mjs → context-CGbVhAmd.mjs} +2 -2
- package/dist/{context-CNIkMzot.mjs → context-CT44ux1O.mjs} +10 -10
- package/dist/{context-route-helpers-MurhoxWF.mjs → context-route-helpers-CcvSXJtQ.mjs} +1 -1
- package/dist/{dashboard-DqnYU8EU.mjs → dashboard-6gH7SlPM.mjs} +9 -18
- package/dist/database/instrumentation.d.mts +1 -1
- package/dist/database/instrumentation.mjs +14 -4
- package/dist/db/index.d.mts +3 -3
- package/dist/db/index.mjs +2 -2
- package/dist/db/libsql.d.mts +1 -1
- package/dist/db/postgres.d.mts +1 -1
- package/dist/db/sqlite.d.mts +1 -1
- package/dist/{device-flow-BGEH5jfn.mjs → device-flow-DaTBhALC.mjs} +5 -5
- package/dist/{dialect-helpers-DhTzaUxP.mjs → dialect-helpers-TkdbkFad.mjs} +7 -1
- package/dist/{fts-manager-B1pTNEG_.mjs → fts-manager-D7KVeBmg.mjs} +1 -1
- package/dist/{hitl-requests-ChT32Ilo.mjs → hitl-requests-CUnch_4e.mjs} +2 -2
- package/dist/{hitl-route-helpers-CSit54Ru.mjs → hitl-route-helpers-DcUCm57p.mjs} +4 -4
- package/dist/{import-BHRLhXAn.mjs → import-BVqG28WP.mjs} +3 -3
- package/dist/{import-CNcKWTbp.mjs → import-DE2ziezs.mjs} +2 -2
- package/dist/{index-CYfhYgXd.d.mts → index-DpMWSamU.d.mts} +2 -2
- package/dist/{index-EUAWaIxW.d.mts → index-JzJUzE4o.d.mts} +47 -47
- package/dist/index.d.mts +16 -16
- package/dist/index.mjs +65 -65
- package/dist/{jsonld-D2gUY4kA.d.mts → jsonld-BjsoTL5m.d.mts} +2 -2
- package/dist/{loader-PZnPxFLc.mjs → loader-CQFxFOt1.mjs} +2 -2
- package/dist/media/index.d.mts +2 -2
- package/dist/media/index.mjs +2 -2
- package/dist/media/local-runtime.d.mts +12 -12
- package/dist/media/local-runtime.mjs +3 -3
- package/dist/{media-_7Fxdu45.mjs → media-Cg4zc9fq.mjs} +12 -9
- package/dist/media-allowlist-eS3AZ2L_.mjs +26 -0
- package/dist/{menus-DYW_UHjv.mjs → menus-BDW1yIdj.mjs} +80 -87
- package/dist/menus-CwI7DQJ5.mjs +569 -0
- package/dist/mime-DJOFDGux.mjs +35 -0
- package/dist/{oauth-authorization-DxGjiWKL.mjs → oauth-authorization-DcYRiDfi.mjs} +5 -5
- package/dist/{oauth-clients-DxO_NO7k.mjs → oauth-clients-CgKFA-VH.mjs} +2 -2
- package/dist/page/index.d.mts +2 -2
- package/dist/page/index.mjs +1 -1
- package/dist/{parse-C9106ehs.mjs → parse-BBfZRZYb.mjs} +1 -1
- package/dist/{placeholder-Bh1dfUOd.d.mts → placeholder-DKMMLt42.d.mts} +1 -1
- package/dist/plugins/adapt-sandbox-entry.d.mts +10 -10
- package/dist/plugins/adapt-sandbox-entry.mjs +1 -1
- package/dist/{plugins-D7-ILNib.mjs → plugins-DKceDtUM.mjs} +9 -7
- package/dist/{preview-DvYRU-Oy.mjs → preview-CIDYFBzd.mjs} +2 -2
- package/dist/{provider-loader-BiQ6lNmf.d.mts → provider-loader-D0F6E2qv.d.mts} +1 -1
- package/dist/{query-CsbOywSY.mjs → query-BtuwuZRd.mjs} +3 -3
- package/dist/{query-B9BO5goQ.mjs → query-CWPxZjGM.mjs} +11 -11
- package/dist/{rate-limit-DmVTHI5v.mjs → rate-limit-GN64_Jaw.mjs} +5 -5
- package/dist/{redirect-CGl64yOX.mjs → redirect-BHo9--Jz.mjs} +3 -3
- package/dist/{redirects-Cgi_cZfN.mjs → redirects-Bc40BgxA.mjs} +4 -4
- package/dist/{redirects-lrlmYXVE.mjs → redirects-xVDvj_yQ.mjs} +68 -15
- package/dist/{registry-C-_hxLqa.mjs → registry-DumDzFDn.mjs} +5 -5
- package/dist/{request-cache-DHMRr2Lf.mjs → request-cache-DmVyQUBh.mjs} +5 -1
- package/dist/request-context.d.mts +19 -1
- package/dist/request-context.mjs +15 -3
- package/dist/{request-meta-DixlNKKa.mjs → request-meta-BVx9KkL-.mjs} +1 -1
- package/dist/{review-requests-C2DIHwlJ.mjs → review-requests-BYuoyse0.mjs} +1 -1
- package/dist/{review-requests-DIyjw-K_.mjs → review-requests-vCw7_3DS.mjs} +1 -1
- package/dist/{runner-BU6Lo1ZS.d.mts → runner-CHR_W79l.d.mts} +1 -1
- package/dist/{runner-DWZm2KQm.mjs → runner-lqEiJbO-.mjs} +496 -181
- package/dist/{runtime-QuuFSlc6.d.mts → runtime-B5hJAnKF.d.mts} +17 -16
- package/dist/runtime.d.mts +11 -11
- package/dist/runtime.mjs +5 -5
- package/dist/{schema-BECjUhP8.mjs → schema-D1z41cq_.mjs} +1 -1
- package/dist/{search-DqTHQqtV.mjs → search-CPcQGTHW.mjs} +2 -2
- package/dist/{secrets-CkoJ9zN0.mjs → secrets-AFKoqUXj.mjs} +2 -2
- package/dist/{sections-B61OxnfB.mjs → sections-B9RYyf3I.mjs} +2 -2
- package/dist/seed/index.d.mts +2 -2
- package/dist/seed/index.mjs +19 -19
- package/dist/seo/index.d.mts +1 -1
- package/dist/{seo-CUQctrog.mjs → seo-BPz1KkCq.mjs} +1 -1
- package/dist/{service-CyOsm0R6.mjs → service-DgiH1Yud.mjs} +2 -2
- package/dist/{settings-Dzgswvg4.mjs → settings-BGCo_c2y.mjs} +1 -1
- package/dist/{settings-DGtLLSaz.mjs → settings-qPzY2KIF.mjs} +4 -4
- package/dist/{setup-complete-ChilE-da.mjs → setup-complete-4EiBS1E5.mjs} +1 -1
- package/dist/{site-activity-B8FjLIVh.mjs → site-activity-lsCX_cqp.mjs} +1 -1
- package/dist/{site-context-WBxoD99D.mjs → site-context-DHRIU6x9.mjs} +58 -34
- package/dist/{site-url-BP7k7OCe.mjs → site-url-oyqzZtoL.mjs} +1 -1
- 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 +1 -1
- package/dist/taxonomies-BWmxbumf.mjs +350 -0
- package/dist/taxonomies-aQXvYVPm.mjs +507 -0
- package/dist/taxonomy-DI-0HgKe.mjs +217 -0
- package/dist/{tokens-BOJw-D9F.mjs → tokens-DB4dASZl.mjs} +1 -1
- package/dist/{types-DZPw8Rru.d.mts → types-CYBaBvtm.d.mts} +9 -0
- package/dist/{types-C0mmVRJN.d.mts → types-CsnHvu4J.d.mts} +1 -0
- package/dist/{types-Bs6lTBBW.mjs → types-D1DjBFA9.mjs} +8 -2
- package/dist/{types-Q616b2Hn.d.mts → types-DS5PYew4.d.mts} +1 -1
- package/dist/ui/server-runtime.d.mts +7 -7
- package/dist/ui/server-runtime.mjs +19 -19
- package/dist/{user-CcXq-zoL.mjs → user-2aI21yV1.mjs} +1 -1
- package/dist/{utils-C0ONdBul.mjs → utils-BJF19gfk.mjs} +1 -1
- package/dist/{validate-C7TzfamJ.mjs → validate-B8ZvLeOE.mjs} +12 -8
- package/dist/{validate-BwmQEbu8.d.mts → validate-BQ24E8rK.d.mts} +21 -4
- package/dist/version-CjsyxeBD.mjs +6 -0
- package/dist/{widgets-B7DRpZvy.mjs → widgets-Cce2-2fM.mjs} +2 -2
- package/dist/{wordpress-slugs-CnporCYH.mjs → wordpress-slugs-C4EhE6fo.mjs} +1 -1
- package/dist/{zod-generator-DBVP8D0P.mjs → zod-generator-BKhtHT3e.mjs} +3 -3
- package/package.json +5 -5
- package/dist/menus-DS3_5nWY.mjs +0 -312
- package/dist/taxonomies-D2aZGuns.mjs +0 -270
- package/dist/taxonomies-z6Lz91BC.mjs +0 -355
- package/dist/taxonomy-D5cbhc8u.mjs +0 -165
- package/dist/version-DzWaHle7.mjs +0 -6
- /package/dist/{adapters-DuLQZhRY.d.mts → adapters-BPzUiHHm.d.mts} +0 -0
- /package/dist/{api-tokens-CPjC3zf8.mjs → api-tokens-B7fvbHM2.mjs} +0 -0
- /package/dist/{base64-Cz-aU0X1.mjs → base64-C1Q9yr0B.mjs} +0 -0
- /package/dist/{challenge-store-DDTbisbf.mjs → challenge-store-anhwVER0.mjs} +0 -0
- /package/dist/{components-BPknylYg.mjs → components-BQiBW_Ji.mjs} +0 -0
- /package/dist/{config-CAMFxGaV.mjs → config-XW5tMrH8.mjs} +0 -0
- /package/dist/{context-types-C-LwdAxx.mjs → context-types-DuiyY6xF.mjs} +0 -0
- /package/dist/{cron-CKxvBrRT.mjs → cron-fV9baRVc.mjs} +0 -0
- /package/dist/{db-errors-DyZkswzF.mjs → db-errors-BnUbfGsK.mjs} +0 -0
- /package/dist/{default-D4ngTpW8.mjs → default-2JDm1rj_.mjs} +0 -0
- /package/dist/{email-console-CuefUXfX.mjs → email-console-_pTim1bU.mjs} +0 -0
- /package/dist/{entity-aliases-C0v-yNET.mjs → entity-aliases-PJV8IxDq.mjs} +0 -0
- /package/dist/{error-BMUPwxgx.mjs → error-Dyf9fGZE.mjs} +0 -0
- /package/dist/{escape-BRVaw1Ai.mjs → escape-Bn168-uP.mjs} +0 -0
- /package/dist/{experimental-workflows-C9X7yblQ.mjs → experimental-workflows-CSRjuEwS.mjs} +0 -0
- /package/dist/{hash-CDX7M0ze.mjs → hash-V8oZo1W2.mjs} +0 -0
- /package/dist/{load-B2XtDw__.mjs → load-BvyvS_76.mjs} +0 -0
- /package/dist/{manifest-schema-CgFJAp0H.mjs → manifest-schema-CU0XL_ZK.mjs} +0 -0
- /package/dist/{mode-DUhxwUhv.mjs → mode-DWw2di1I.mjs} +0 -0
- /package/dist/{normalize-C49G_o1k.mjs → normalize-9GU-bv_T.mjs} +0 -0
- /package/dist/{oauth-state-store-C5UFhzwD.mjs → oauth-state-store-DhifLitQ.mjs} +0 -0
- /package/dist/{oauth-user-lookup-Bi0ek9eM.mjs → oauth-user-lookup-nyXQ2_6Q.mjs} +0 -0
- /package/dist/{options-z8VVg1Ll.mjs → options-BF11H_FD.mjs} +0 -0
- /package/dist/{passkey-config-BRSZx4pW.mjs → passkey-config-DZOjt0Hd.mjs} +0 -0
- /package/dist/{patterns-K0DLqWir.mjs → patterns-CW4n2PQs.mjs} +0 -0
- /package/dist/{placeholder-C2P5fKa4.mjs → placeholder-BJPmhjHP.mjs} +0 -0
- /package/dist/{provider-loader-C21b9OpH.mjs → provider-loader-Decn0Ktc.mjs} +0 -0
- /package/dist/{public-url-Cun8N3NU.mjs → public-url-5fFLJhjh.mjs} +0 -0
- /package/dist/{redirect-COZy-3iY.mjs → redirect-C077gVTf.mjs} +0 -0
- /package/dist/{seo-C007Luwn.mjs → seo-DJoop90w.mjs} +0 -0
- /package/dist/{seo-contributions-B1fWCnqY.mjs → seo-contributions-CQzUjJKY.mjs} +0 -0
- /package/dist/{setup-nonce-BpmLXAuu.mjs → setup-nonce-DN6BHIlP.mjs} +0 -0
- /package/dist/{sidecar-client-B1C6Cf80.mjs → sidecar-client-Dta0AELf.mjs} +0 -0
- /package/dist/{slugify-PDTDtMXp.mjs → slugify-BzGxlOFx.mjs} +0 -0
- /package/dist/{ssrf-DDwRxF6B.mjs → ssrf-BOSGjXxb.mjs} +0 -0
- /package/dist/{transaction-x2tJQ-A1.mjs → transaction-qfqpPVpu.mjs} +0 -0
- /package/dist/{transport-D3i4yWRE.mjs → transport-B3jxvfio.mjs} +0 -0
- /package/dist/{transport-BXe1AM79.d.mts → transport-CyOHECBA.d.mts} +0 -0
- /package/dist/{trusted-proxy-BbaZfkT9.mjs → trusted-proxy-8N8sX1D1.mjs} +0 -0
- /package/dist/{types-DJlpx5Ay.d.mts → types-6N-00csp.d.mts} +0 -0
- /package/dist/{types-BFmjniC2.d.mts → types-B45uSz1j.d.mts} +0 -0
- /package/dist/{types-B7kpsMJ3.d.mts → types-BDm7Ipoq.d.mts} +0 -0
- /package/dist/{types-0Vr68fc2.d.mts → types-BeYn-Yf0.d.mts} +0 -0
- /package/dist/{types-OPs5Q_sX.d.mts → types-D_wGrwiY.d.mts} +0 -0
- /package/dist/{types-DL7Y8D_t.mjs → types-Dz2EKzsX.mjs} +0 -0
- /package/dist/{types-fAInWQDO.mjs → types-iNqHe2-V.mjs} +0 -0
- /package/dist/{url-DNjT2abR.mjs → url-DOS4RGym.mjs} +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-ClPoSABd.mjs";
|
|
2
2
|
import { t as validateIdentifier } from "./validate-VPnKoIzW.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { c as listTablesLike, i as currentTimestampValue, n as columnExists, o as isSqlite, r as currentTimestamp, t as binaryType } from "./dialect-helpers-TkdbkFad.mjs";
|
|
4
|
+
import { n as getI18nConfig } from "./config-XW5tMrH8.mjs";
|
|
4
5
|
import { Migrator, sql } from "kysely";
|
|
5
6
|
|
|
6
7
|
//#region src/database/migrations/001_initial.ts
|
|
7
8
|
var _001_initial_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
-
down: () => down$
|
|
9
|
-
up: () => up$
|
|
9
|
+
down: () => down$43,
|
|
10
|
+
up: () => up$43
|
|
10
11
|
});
|
|
11
12
|
/**
|
|
12
13
|
* Initial schema migration
|
|
@@ -15,7 +16,7 @@ var _001_initial_exports = /* @__PURE__ */ __exportAll({
|
|
|
15
16
|
* by the SchemaRegistry when collections are added via the admin UI.
|
|
16
17
|
* This migration only creates system tables.
|
|
17
18
|
*/
|
|
18
|
-
async function up$
|
|
19
|
+
async function up$43(db) {
|
|
19
20
|
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(db))).execute();
|
|
20
21
|
await db.schema.createIndex("idx_revisions_entry").ifNotExists().on("revisions").columns(["collection", "entry_id"]).execute();
|
|
21
22
|
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();
|
|
@@ -35,7 +36,7 @@ async function up$41(db) {
|
|
|
35
36
|
await db.schema.createIndex("idx_audit_action").ifNotExists().on("audit_logs").column("action").execute();
|
|
36
37
|
await db.schema.createIndex("idx_audit_timestamp").ifNotExists().on("audit_logs").column("timestamp").execute();
|
|
37
38
|
}
|
|
38
|
-
async function down$
|
|
39
|
+
async function down$43(db) {
|
|
39
40
|
await db.schema.dropTable("audit_logs").execute();
|
|
40
41
|
await db.schema.dropTable("options").execute();
|
|
41
42
|
await db.schema.dropTable("users").execute();
|
|
@@ -48,26 +49,26 @@ async function down$41(db) {
|
|
|
48
49
|
//#endregion
|
|
49
50
|
//#region src/database/migrations/002_media_status.ts
|
|
50
51
|
var _002_media_status_exports = /* @__PURE__ */ __exportAll({
|
|
51
|
-
down: () => down$
|
|
52
|
-
up: () => up$
|
|
52
|
+
down: () => down$42,
|
|
53
|
+
up: () => up$42
|
|
53
54
|
});
|
|
54
55
|
/**
|
|
55
56
|
* Add status column to media table for tracking upload state.
|
|
56
57
|
* Status values: 'pending' | 'ready' | 'failed'
|
|
57
58
|
*/
|
|
58
|
-
async function up$
|
|
59
|
+
async function up$42(db) {
|
|
59
60
|
await db.schema.alterTable("media").addColumn("status", "text", (col) => col.notNull().defaultTo("ready")).execute();
|
|
60
61
|
await db.schema.createIndex("idx_media_status").on("media").column("status").execute();
|
|
61
62
|
}
|
|
62
|
-
async function down$
|
|
63
|
+
async function down$42(db) {
|
|
63
64
|
await db.schema.dropIndex("idx_media_status").execute();
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
//#endregion
|
|
67
68
|
//#region src/database/migrations/003_schema_registry.ts
|
|
68
69
|
var _003_schema_registry_exports = /* @__PURE__ */ __exportAll({
|
|
69
|
-
down: () => down$
|
|
70
|
-
up: () => up$
|
|
70
|
+
down: () => down$41,
|
|
71
|
+
up: () => up$41
|
|
71
72
|
});
|
|
72
73
|
/**
|
|
73
74
|
* Migration: Schema Registry Tables
|
|
@@ -75,14 +76,14 @@ var _003_schema_registry_exports = /* @__PURE__ */ __exportAll({
|
|
|
75
76
|
* Creates the schema registry tables that store collection and field definitions.
|
|
76
77
|
* This enables dynamic schema management where the database is the source of truth.
|
|
77
78
|
*/
|
|
78
|
-
async function up$
|
|
79
|
+
async function up$41(db) {
|
|
79
80
|
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(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp(db))).execute();
|
|
80
81
|
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(db))).addForeignKeyConstraint("fields_collection_fk", ["collection_id"], "_dineway_collections", ["id"], (cb) => cb.onDelete("cascade")).execute();
|
|
81
82
|
await db.schema.createIndex("idx_fields_collection_slug").on("_dineway_fields").columns(["collection_id", "slug"]).unique().execute();
|
|
82
83
|
await db.schema.createIndex("idx_fields_collection").on("_dineway_fields").column("collection_id").execute();
|
|
83
84
|
await db.schema.createIndex("idx_fields_sort").on("_dineway_fields").columns(["collection_id", "sort_order"]).execute();
|
|
84
85
|
}
|
|
85
|
-
async function down$
|
|
86
|
+
async function down$41(db) {
|
|
86
87
|
await db.schema.dropTable("_dineway_fields").execute();
|
|
87
88
|
await db.schema.dropTable("_dineway_collections").execute();
|
|
88
89
|
}
|
|
@@ -90,8 +91,8 @@ async function down$39(db) {
|
|
|
90
91
|
//#endregion
|
|
91
92
|
//#region src/database/migrations/004_plugins.ts
|
|
92
93
|
var _004_plugins_exports = /* @__PURE__ */ __exportAll({
|
|
93
|
-
down: () => down$
|
|
94
|
-
up: () => up$
|
|
94
|
+
down: () => down$40,
|
|
95
|
+
up: () => up$40
|
|
95
96
|
});
|
|
96
97
|
/**
|
|
97
98
|
* Migration: Plugin System Tables
|
|
@@ -101,7 +102,7 @@ var _004_plugins_exports = /* @__PURE__ */ __exportAll({
|
|
|
101
102
|
*
|
|
102
103
|
* @see PLUGIN-SYSTEM.md § Plugin Storage
|
|
103
104
|
*/
|
|
104
|
-
async function up$
|
|
105
|
+
async function up$40(db) {
|
|
105
106
|
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(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp(db))).addPrimaryKeyConstraint("pk_plugin_storage", [
|
|
106
107
|
"plugin_id",
|
|
107
108
|
"collection",
|
|
@@ -119,7 +120,7 @@ async function up$38(db) {
|
|
|
119
120
|
"index_name"
|
|
120
121
|
]).execute();
|
|
121
122
|
}
|
|
122
|
-
async function down$
|
|
123
|
+
async function down$40(db) {
|
|
123
124
|
await db.schema.dropTable("_plugin_indexes").execute();
|
|
124
125
|
await db.schema.dropTable("_plugin_state").execute();
|
|
125
126
|
await db.schema.dropTable("_plugin_storage").execute();
|
|
@@ -128,8 +129,8 @@ async function down$38(db) {
|
|
|
128
129
|
//#endregion
|
|
129
130
|
//#region src/database/migrations/005_menus.ts
|
|
130
131
|
var _005_menus_exports = /* @__PURE__ */ __exportAll({
|
|
131
|
-
down: () => down$
|
|
132
|
-
up: () => up$
|
|
132
|
+
down: () => down$39,
|
|
133
|
+
up: () => up$39
|
|
133
134
|
});
|
|
134
135
|
/**
|
|
135
136
|
* Navigation Menus migration
|
|
@@ -137,13 +138,13 @@ var _005_menus_exports = /* @__PURE__ */ __exportAll({
|
|
|
137
138
|
* Creates tables for admin-editable navigation menus.
|
|
138
139
|
* Menu items can reference content entries, taxonomy terms, or custom URLs.
|
|
139
140
|
*/
|
|
140
|
-
async function up$
|
|
141
|
+
async function up$39(db) {
|
|
141
142
|
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(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp(db))).execute();
|
|
142
143
|
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(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();
|
|
143
144
|
await db.schema.createIndex("idx_menu_items_menu").on("_dineway_menu_items").columns(["menu_id", "sort_order"]).execute();
|
|
144
145
|
await db.schema.createIndex("idx_menu_items_parent").on("_dineway_menu_items").column("parent_id").execute();
|
|
145
146
|
}
|
|
146
|
-
async function down$
|
|
147
|
+
async function down$39(db) {
|
|
147
148
|
await db.schema.dropTable("_dineway_menu_items").execute();
|
|
148
149
|
await db.schema.dropTable("_dineway_menus").execute();
|
|
149
150
|
}
|
|
@@ -151,8 +152,8 @@ async function down$37(db) {
|
|
|
151
152
|
//#endregion
|
|
152
153
|
//#region src/database/migrations/006_taxonomy_defs.ts
|
|
153
154
|
var _006_taxonomy_defs_exports = /* @__PURE__ */ __exportAll({
|
|
154
|
-
down: () => down$
|
|
155
|
-
up: () => up$
|
|
155
|
+
down: () => down$38,
|
|
156
|
+
up: () => up$38
|
|
156
157
|
});
|
|
157
158
|
/**
|
|
158
159
|
* Taxonomy definitions migration
|
|
@@ -160,7 +161,7 @@ var _006_taxonomy_defs_exports = /* @__PURE__ */ __exportAll({
|
|
|
160
161
|
* Adds _dineway_taxonomy_defs table to store taxonomy definitions (category, tag, custom)
|
|
161
162
|
* and seeds default category and tag taxonomies.
|
|
162
163
|
*/
|
|
163
|
-
async function up$
|
|
164
|
+
async function up$38(db) {
|
|
164
165
|
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(db))).execute();
|
|
165
166
|
await db.insertInto("_dineway_taxonomy_defs").values([{
|
|
166
167
|
id: "taxdef_category",
|
|
@@ -178,22 +179,22 @@ async function up$36(db) {
|
|
|
178
179
|
collections: JSON.stringify(["posts"])
|
|
179
180
|
}]).execute();
|
|
180
181
|
}
|
|
181
|
-
async function down$
|
|
182
|
+
async function down$38(db) {
|
|
182
183
|
await db.schema.dropTable("_dineway_taxonomy_defs").execute();
|
|
183
184
|
}
|
|
184
185
|
|
|
185
186
|
//#endregion
|
|
186
187
|
//#region src/database/migrations/007_widgets.ts
|
|
187
188
|
var _007_widgets_exports = /* @__PURE__ */ __exportAll({
|
|
188
|
-
down: () => down$
|
|
189
|
-
up: () => up$
|
|
189
|
+
down: () => down$37,
|
|
190
|
+
up: () => up$37
|
|
190
191
|
});
|
|
191
|
-
async function up$
|
|
192
|
+
async function up$37(db) {
|
|
192
193
|
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();
|
|
193
194
|
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();
|
|
194
195
|
await db.schema.createIndex("idx_widgets_area").on("_dineway_widgets").columns(["area_id", "sort_order"]).execute();
|
|
195
196
|
}
|
|
196
|
-
async function down$
|
|
197
|
+
async function down$37(db) {
|
|
197
198
|
await db.schema.dropTable("_dineway_widgets").execute();
|
|
198
199
|
await db.schema.dropTable("_dineway_widget_areas").execute();
|
|
199
200
|
}
|
|
@@ -201,8 +202,8 @@ async function down$35(db) {
|
|
|
201
202
|
//#endregion
|
|
202
203
|
//#region src/database/migrations/008_auth.ts
|
|
203
204
|
var _008_auth_exports = /* @__PURE__ */ __exportAll({
|
|
204
|
-
down: () => down$
|
|
205
|
-
up: () => up$
|
|
205
|
+
down: () => down$36,
|
|
206
|
+
up: () => up$36
|
|
206
207
|
});
|
|
207
208
|
/**
|
|
208
209
|
* Auth migration - passkey-first authentication
|
|
@@ -216,7 +217,7 @@ var _008_auth_exports = /* @__PURE__ */ __exportAll({
|
|
|
216
217
|
* - Creates oauth_accounts table (external provider links)
|
|
217
218
|
* - Creates allowed_domains table (self-signup)
|
|
218
219
|
*/
|
|
219
|
-
async function up$
|
|
220
|
+
async function up$36(db) {
|
|
220
221
|
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(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp(db))).execute();
|
|
221
222
|
await sql`
|
|
222
223
|
INSERT INTO users_new (id, email, name, role, data, created_at, updated_at)
|
|
@@ -239,7 +240,7 @@ async function up$34(db) {
|
|
|
239
240
|
await db.schema.dropTable("users").execute();
|
|
240
241
|
await sql`ALTER TABLE users_new RENAME TO users`.execute(db);
|
|
241
242
|
await db.schema.createIndex("idx_users_email").on("users").column("email").execute();
|
|
242
|
-
await db.schema.createTable("credentials").addColumn("id", "text", (col) => col.primaryKey()).addColumn("user_id", "text", (col) => col.notNull()).addColumn("public_key", binaryType(db), (col) => col.notNull()).addColumn("counter", "integer", (col) => col.notNull().defaultTo(0)).addColumn("device_type", "text", (col) => col.notNull()).addColumn("backed_up", "integer", (col) => col.notNull().defaultTo(0)).addColumn("transports", "text").addColumn("name", "text").addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp(db))).addColumn("last_used_at", "text", (col) => col.defaultTo(currentTimestamp(db))).addForeignKeyConstraint("credentials_user_fk", ["user_id"], "users", ["id"], (cb) => cb.onDelete("cascade")).execute();
|
|
243
|
+
await db.schema.createTable("credentials").addColumn("id", "text", (col) => col.primaryKey()).addColumn("user_id", "text", (col) => col.notNull()).addColumn("public_key", binaryType(db), (col) => col.notNull()).addColumn("algorithm", "integer", (col) => col.notNull().defaultTo(-7)).addColumn("counter", "integer", (col) => col.notNull().defaultTo(0)).addColumn("device_type", "text", (col) => col.notNull()).addColumn("backed_up", "integer", (col) => col.notNull().defaultTo(0)).addColumn("transports", "text").addColumn("name", "text").addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp(db))).addColumn("last_used_at", "text", (col) => col.defaultTo(currentTimestamp(db))).addForeignKeyConstraint("credentials_user_fk", ["user_id"], "users", ["id"], (cb) => cb.onDelete("cascade")).execute();
|
|
243
244
|
await db.schema.createIndex("idx_credentials_user").on("credentials").column("user_id").execute();
|
|
244
245
|
await db.schema.createTable("auth_tokens").addColumn("hash", "text", (col) => col.primaryKey()).addColumn("user_id", "text").addColumn("email", "text").addColumn("type", "text", (col) => col.notNull()).addColumn("role", "integer").addColumn("invited_by", "text").addColumn("expires_at", "text", (col) => col.notNull()).addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp(db))).addForeignKeyConstraint("auth_tokens_user_fk", ["user_id"], "users", ["id"], (cb) => cb.onDelete("cascade")).addForeignKeyConstraint("auth_tokens_invited_by_fk", ["invited_by"], "users", ["id"], (cb) => cb.onDelete("set null")).execute();
|
|
245
246
|
await db.schema.createIndex("idx_auth_tokens_email").on("auth_tokens").column("email").execute();
|
|
@@ -249,7 +250,7 @@ async function up$34(db) {
|
|
|
249
250
|
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(db))).execute();
|
|
250
251
|
await db.schema.createIndex("idx_auth_challenges_expires").on("auth_challenges").column("expires_at").execute();
|
|
251
252
|
}
|
|
252
|
-
async function down$
|
|
253
|
+
async function down$36(db) {
|
|
253
254
|
await db.schema.dropTable("auth_challenges").execute();
|
|
254
255
|
await db.schema.dropTable("allowed_domains").execute();
|
|
255
256
|
await db.schema.dropTable("oauth_accounts").execute();
|
|
@@ -282,8 +283,8 @@ async function down$34(db) {
|
|
|
282
283
|
//#endregion
|
|
283
284
|
//#region src/database/migrations/009_user_disabled.ts
|
|
284
285
|
var _009_user_disabled_exports = /* @__PURE__ */ __exportAll({
|
|
285
|
-
down: () => down$
|
|
286
|
-
up: () => up$
|
|
286
|
+
down: () => down$35,
|
|
287
|
+
up: () => up$35
|
|
287
288
|
});
|
|
288
289
|
/**
|
|
289
290
|
* User disabled column - for soft-disabling users
|
|
@@ -292,19 +293,19 @@ var _009_user_disabled_exports = /* @__PURE__ */ __exportAll({
|
|
|
292
293
|
* - Adds disabled column to users table (INTEGER, default 0)
|
|
293
294
|
* - Disabled users cannot log in
|
|
294
295
|
*/
|
|
295
|
-
async function up$
|
|
296
|
+
async function up$35(db) {
|
|
296
297
|
await sql`ALTER TABLE users ADD COLUMN disabled INTEGER NOT NULL DEFAULT 0`.execute(db);
|
|
297
298
|
await db.schema.createIndex("idx_users_disabled").on("users").column("disabled").execute();
|
|
298
299
|
}
|
|
299
|
-
async function down$
|
|
300
|
+
async function down$35(db) {
|
|
300
301
|
await db.schema.dropIndex("idx_users_disabled").execute();
|
|
301
302
|
}
|
|
302
303
|
|
|
303
304
|
//#endregion
|
|
304
305
|
//#region src/database/migrations/011_sections.ts
|
|
305
306
|
var _011_sections_exports = /* @__PURE__ */ __exportAll({
|
|
306
|
-
down: () => down$
|
|
307
|
-
up: () => up$
|
|
307
|
+
down: () => down$34,
|
|
308
|
+
up: () => up$34
|
|
308
309
|
});
|
|
309
310
|
/**
|
|
310
311
|
* Migration: Add sections tables and performance indexes
|
|
@@ -313,13 +314,13 @@ var _011_sections_exports = /* @__PURE__ */ __exportAll({
|
|
|
313
314
|
* They provide a library of pre-built page sections (heroes, CTAs, testimonials, etc.)
|
|
314
315
|
* that content authors can browse and insert with a single click.
|
|
315
316
|
*/
|
|
316
|
-
async function up$
|
|
317
|
+
async function up$34(db) {
|
|
317
318
|
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();
|
|
318
319
|
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();
|
|
319
320
|
await db.schema.createIndex("idx_sections_category").on("_dineway_sections").columns(["category_id"]).execute();
|
|
320
321
|
await db.schema.createIndex("idx_sections_source").on("_dineway_sections").columns(["source"]).execute();
|
|
321
322
|
}
|
|
322
|
-
async function down$
|
|
323
|
+
async function down$34(db) {
|
|
323
324
|
await db.schema.dropIndex("idx_sections_source").execute();
|
|
324
325
|
await db.schema.dropIndex("idx_sections_category").execute();
|
|
325
326
|
await db.schema.dropTable("_dineway_sections").execute();
|
|
@@ -329,8 +330,8 @@ async function down$32(db) {
|
|
|
329
330
|
//#endregion
|
|
330
331
|
//#region src/database/migrations/012_search.ts
|
|
331
332
|
var _012_search_exports = /* @__PURE__ */ __exportAll({
|
|
332
|
-
down: () => down$
|
|
333
|
-
up: () => up$
|
|
333
|
+
down: () => down$33,
|
|
334
|
+
up: () => up$33
|
|
334
335
|
});
|
|
335
336
|
/**
|
|
336
337
|
* Migration: Search Support
|
|
@@ -338,11 +339,11 @@ var _012_search_exports = /* @__PURE__ */ __exportAll({
|
|
|
338
339
|
* Adds search configuration to collections and searchable flag to fields.
|
|
339
340
|
* FTS5 tables are created dynamically when search is enabled for a collection.
|
|
340
341
|
*/
|
|
341
|
-
async function up$
|
|
342
|
+
async function up$33(db) {
|
|
342
343
|
await db.schema.alterTable("_dineway_collections").addColumn("search_config", "text").execute();
|
|
343
344
|
await db.schema.alterTable("_dineway_fields").addColumn("searchable", "integer", (col) => col.defaultTo(0)).execute();
|
|
344
345
|
}
|
|
345
|
-
async function down$
|
|
346
|
+
async function down$33(db) {
|
|
346
347
|
await db.schema.alterTable("_dineway_fields").dropColumn("searchable").execute();
|
|
347
348
|
await db.schema.alterTable("_dineway_collections").dropColumn("search_config").execute();
|
|
348
349
|
}
|
|
@@ -350,8 +351,8 @@ async function down$31(db) {
|
|
|
350
351
|
//#endregion
|
|
351
352
|
//#region src/database/migrations/013_scheduled_publishing.ts
|
|
352
353
|
var _013_scheduled_publishing_exports = /* @__PURE__ */ __exportAll({
|
|
353
|
-
down: () => down$
|
|
354
|
-
up: () => up$
|
|
354
|
+
down: () => down$32,
|
|
355
|
+
up: () => up$32
|
|
355
356
|
});
|
|
356
357
|
/**
|
|
357
358
|
* Migration: Add scheduled publishing support
|
|
@@ -360,7 +361,7 @@ var _013_scheduled_publishing_exports = /* @__PURE__ */ __exportAll({
|
|
|
360
361
|
* When scheduled_at is set and status is 'scheduled', the content
|
|
361
362
|
* will be auto-published when the scheduled time is reached.
|
|
362
363
|
*/
|
|
363
|
-
async function up$
|
|
364
|
+
async function up$32(db) {
|
|
364
365
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
365
366
|
for (const tableName of tableNames) {
|
|
366
367
|
const table = { name: tableName };
|
|
@@ -375,7 +376,7 @@ async function up$30(db) {
|
|
|
375
376
|
`.execute(db);
|
|
376
377
|
}
|
|
377
378
|
}
|
|
378
|
-
async function down$
|
|
379
|
+
async function down$32(db) {
|
|
379
380
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
380
381
|
for (const tableName of tableNames) {
|
|
381
382
|
const table = { name: tableName };
|
|
@@ -392,10 +393,10 @@ async function down$30(db) {
|
|
|
392
393
|
//#endregion
|
|
393
394
|
//#region src/database/migrations/014_draft_revisions.ts
|
|
394
395
|
var _014_draft_revisions_exports = /* @__PURE__ */ __exportAll({
|
|
395
|
-
down: () => down$
|
|
396
|
-
up: () => up$
|
|
396
|
+
down: () => down$31,
|
|
397
|
+
up: () => up$31
|
|
397
398
|
});
|
|
398
|
-
async function up$
|
|
399
|
+
async function up$31(db) {
|
|
399
400
|
const tables = await db.selectFrom("_dineway_collections").select("slug").execute();
|
|
400
401
|
for (const row of tables) {
|
|
401
402
|
const tableName = `ec_${row.slug}`;
|
|
@@ -417,7 +418,7 @@ async function up$29(db) {
|
|
|
417
418
|
`.execute(db);
|
|
418
419
|
}
|
|
419
420
|
}
|
|
420
|
-
async function down$
|
|
421
|
+
async function down$31(db) {
|
|
421
422
|
const tables = await db.selectFrom("_dineway_collections").select("slug").execute();
|
|
422
423
|
for (const row of tables) {
|
|
423
424
|
const tableName = `ec_${row.slug}`;
|
|
@@ -441,8 +442,8 @@ async function down$29(db) {
|
|
|
441
442
|
//#endregion
|
|
442
443
|
//#region src/database/migrations/015_indexes.ts
|
|
443
444
|
var _015_indexes_exports = /* @__PURE__ */ __exportAll({
|
|
444
|
-
down: () => down$
|
|
445
|
-
up: () => up$
|
|
445
|
+
down: () => down$30,
|
|
446
|
+
up: () => up$30
|
|
446
447
|
});
|
|
447
448
|
/**
|
|
448
449
|
* Add performance indexes for common query patterns.
|
|
@@ -455,7 +456,7 @@ var _015_indexes_exports = /* @__PURE__ */ __exportAll({
|
|
|
455
456
|
* 5. Retroactive author_id + updated_at on existing ec_* content tables
|
|
456
457
|
* (new tables get these from createContentTable() in registry.ts)
|
|
457
458
|
*/
|
|
458
|
-
async function up$
|
|
459
|
+
async function up$30(db) {
|
|
459
460
|
await db.schema.createIndex("idx_media_mime_type").on("media").column("mime_type").execute();
|
|
460
461
|
await db.schema.createIndex("idx_media_filename").on("media").column("filename").execute();
|
|
461
462
|
await db.schema.createIndex("idx_media_created_at").on("media").column("created_at").execute();
|
|
@@ -475,7 +476,7 @@ async function up$28(db) {
|
|
|
475
476
|
`.execute(db);
|
|
476
477
|
}
|
|
477
478
|
}
|
|
478
|
-
async function down$
|
|
479
|
+
async function down$30(db) {
|
|
479
480
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
480
481
|
for (const tableName of tableNames) {
|
|
481
482
|
const table = { name: tableName };
|
|
@@ -493,8 +494,8 @@ async function down$28(db) {
|
|
|
493
494
|
//#endregion
|
|
494
495
|
//#region src/database/migrations/016_api_tokens.ts
|
|
495
496
|
var _016_api_tokens_exports = /* @__PURE__ */ __exportAll({
|
|
496
|
-
down: () => down$
|
|
497
|
-
up: () => up$
|
|
497
|
+
down: () => down$29,
|
|
498
|
+
up: () => up$29
|
|
498
499
|
});
|
|
499
500
|
/**
|
|
500
501
|
* API token tables for programmatic access.
|
|
@@ -503,27 +504,31 @@ var _016_api_tokens_exports = /* @__PURE__ */ __exportAll({
|
|
|
503
504
|
* 1. _dineway_api_tokens — Personal Access Tokens (ec_pat_...)
|
|
504
505
|
* 2. _dineway_oauth_tokens — OAuth access/refresh tokens (ec_oat_/ec_ort_...)
|
|
505
506
|
* 3. _dineway_device_codes — OAuth Device Flow state (RFC 8628)
|
|
507
|
+
*
|
|
508
|
+
* Every CREATE is guarded so this migration can recover if a previous run
|
|
509
|
+
* created only part of the schema before failing and never recorded the
|
|
510
|
+
* migration as applied.
|
|
506
511
|
*/
|
|
507
|
-
async function up$
|
|
508
|
-
await db.schema.createTable("_dineway_api_tokens").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(db))).addForeignKeyConstraint("api_tokens_user_fk", ["user_id"], "users", ["id"], (cb) => cb.onDelete("cascade")).execute();
|
|
509
|
-
await db.schema.createIndex("idx_api_tokens_token_hash").on("_dineway_api_tokens").column("token_hash").execute();
|
|
510
|
-
await db.schema.createIndex("idx_api_tokens_user_id").on("_dineway_api_tokens").column("user_id").execute();
|
|
511
|
-
await db.schema.createTable("_dineway_oauth_tokens").addColumn("token_hash", "text", (col) => col.primaryKey()).addColumn("token_type", "text", (col) => col.notNull()).addColumn("user_id", "text", (col) => col.notNull()).addColumn("scopes", "text", (col) => col.notNull()).addColumn("client_type", "text", (col) => col.notNull().defaultTo("cli")).addColumn("expires_at", "text", (col) => col.notNull()).addColumn("refresh_token_hash", "text").addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp(db))).addForeignKeyConstraint("oauth_tokens_user_fk", ["user_id"], "users", ["id"], (cb) => cb.onDelete("cascade")).execute();
|
|
512
|
-
await db.schema.createIndex("idx_oauth_tokens_user_id").on("_dineway_oauth_tokens").column("user_id").execute();
|
|
513
|
-
await db.schema.createIndex("idx_oauth_tokens_expires").on("_dineway_oauth_tokens").column("expires_at").execute();
|
|
514
|
-
await db.schema.createTable("_dineway_device_codes").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(db))).execute();
|
|
512
|
+
async function up$29(db) {
|
|
513
|
+
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(db))).addForeignKeyConstraint("api_tokens_user_fk", ["user_id"], "users", ["id"], (cb) => cb.onDelete("cascade")).execute();
|
|
514
|
+
await db.schema.createIndex("idx_api_tokens_token_hash").ifNotExists().on("_dineway_api_tokens").column("token_hash").execute();
|
|
515
|
+
await db.schema.createIndex("idx_api_tokens_user_id").ifNotExists().on("_dineway_api_tokens").column("user_id").execute();
|
|
516
|
+
await db.schema.createTable("_dineway_oauth_tokens").ifNotExists().addColumn("token_hash", "text", (col) => col.primaryKey()).addColumn("token_type", "text", (col) => col.notNull()).addColumn("user_id", "text", (col) => col.notNull()).addColumn("scopes", "text", (col) => col.notNull()).addColumn("client_type", "text", (col) => col.notNull().defaultTo("cli")).addColumn("expires_at", "text", (col) => col.notNull()).addColumn("refresh_token_hash", "text").addColumn("created_at", "text", (col) => col.defaultTo(currentTimestamp(db))).addForeignKeyConstraint("oauth_tokens_user_fk", ["user_id"], "users", ["id"], (cb) => cb.onDelete("cascade")).execute();
|
|
517
|
+
await db.schema.createIndex("idx_oauth_tokens_user_id").ifNotExists().on("_dineway_oauth_tokens").column("user_id").execute();
|
|
518
|
+
await db.schema.createIndex("idx_oauth_tokens_expires").ifNotExists().on("_dineway_oauth_tokens").column("expires_at").execute();
|
|
519
|
+
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(db))).execute();
|
|
515
520
|
}
|
|
516
|
-
async function down$
|
|
517
|
-
await db.schema.dropTable("_dineway_device_codes").execute();
|
|
518
|
-
await db.schema.dropTable("_dineway_oauth_tokens").execute();
|
|
519
|
-
await db.schema.dropTable("_dineway_api_tokens").execute();
|
|
521
|
+
async function down$29(db) {
|
|
522
|
+
await db.schema.dropTable("_dineway_device_codes").ifExists().execute();
|
|
523
|
+
await db.schema.dropTable("_dineway_oauth_tokens").ifExists().execute();
|
|
524
|
+
await db.schema.dropTable("_dineway_api_tokens").ifExists().execute();
|
|
520
525
|
}
|
|
521
526
|
|
|
522
527
|
//#endregion
|
|
523
528
|
//#region src/database/migrations/017_authorization_codes.ts
|
|
524
529
|
var _017_authorization_codes_exports = /* @__PURE__ */ __exportAll({
|
|
525
|
-
down: () => down$
|
|
526
|
-
up: () => up$
|
|
530
|
+
down: () => down$28,
|
|
531
|
+
up: () => up$28
|
|
527
532
|
});
|
|
528
533
|
/**
|
|
529
534
|
* Authorization codes for OAuth 2.1 Authorization Code + PKCE flow.
|
|
@@ -533,20 +538,20 @@ var _017_authorization_codes_exports = /* @__PURE__ */ __exportAll({
|
|
|
533
538
|
*
|
|
534
539
|
* Also adds client_id tracking to oauth_tokens for per-client revocation.
|
|
535
540
|
*/
|
|
536
|
-
async function up$
|
|
541
|
+
async function up$28(db) {
|
|
537
542
|
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(db))).addForeignKeyConstraint("auth_codes_user_fk", ["user_id"], "users", ["id"], (cb) => cb.onDelete("cascade")).execute();
|
|
538
543
|
await db.schema.createIndex("idx_auth_codes_expires").on("_dineway_authorization_codes").column("expires_at").execute();
|
|
539
544
|
await sql`ALTER TABLE _dineway_oauth_tokens ADD COLUMN client_id TEXT`.execute(db);
|
|
540
545
|
}
|
|
541
|
-
async function down$
|
|
546
|
+
async function down$28(db) {
|
|
542
547
|
await db.schema.dropTable("_dineway_authorization_codes").execute();
|
|
543
548
|
}
|
|
544
549
|
|
|
545
550
|
//#endregion
|
|
546
551
|
//#region src/database/migrations/018_seo.ts
|
|
547
552
|
var _018_seo_exports = /* @__PURE__ */ __exportAll({
|
|
548
|
-
down: () => down$
|
|
549
|
-
up: () => up$
|
|
553
|
+
down: () => down$27,
|
|
554
|
+
up: () => up$27
|
|
550
555
|
});
|
|
551
556
|
/**
|
|
552
557
|
* Migration: SEO support
|
|
@@ -559,7 +564,7 @@ var _018_seo_exports = /* @__PURE__ */ __exportAll({
|
|
|
559
564
|
* need it. The `has_seo` flag controls whether the admin shows SEO fields
|
|
560
565
|
* and whether the collection's content appears in sitemaps.
|
|
561
566
|
*/
|
|
562
|
-
async function up$
|
|
567
|
+
async function up$27(db) {
|
|
563
568
|
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(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp(db))).addPrimaryKeyConstraint("_dineway_seo_pk", ["collection", "content_id"]).execute();
|
|
564
569
|
await sql`
|
|
565
570
|
CREATE INDEX idx_dineway_seo_collection
|
|
@@ -570,7 +575,7 @@ async function up$25(db) {
|
|
|
570
575
|
ADD COLUMN has_seo INTEGER NOT NULL DEFAULT 0
|
|
571
576
|
`.execute(db);
|
|
572
577
|
}
|
|
573
|
-
async function down$
|
|
578
|
+
async function down$27(db) {
|
|
574
579
|
await sql`DROP TABLE IF EXISTS _dineway_seo`.execute(db);
|
|
575
580
|
await sql`
|
|
576
581
|
ALTER TABLE _dineway_collections
|
|
@@ -581,8 +586,8 @@ async function down$25(db) {
|
|
|
581
586
|
//#endregion
|
|
582
587
|
//#region src/database/migrations/019_i18n.ts
|
|
583
588
|
var _019_i18n_exports = /* @__PURE__ */ __exportAll({
|
|
584
|
-
down: () => down$
|
|
585
|
-
up: () => up$
|
|
589
|
+
down: () => down$26,
|
|
590
|
+
up: () => up$26
|
|
586
591
|
});
|
|
587
592
|
/**
|
|
588
593
|
* Quote an identifier for use in raw SQL. Escapes embedded double-quotes
|
|
@@ -695,7 +700,7 @@ async function upPostgres(db) {
|
|
|
695
700
|
ADD COLUMN translatable INTEGER NOT NULL DEFAULT 1
|
|
696
701
|
`.execute(db);
|
|
697
702
|
}
|
|
698
|
-
async function up$
|
|
703
|
+
async function up$26(db) {
|
|
699
704
|
if (!isSqlite(db)) return upPostgres(db);
|
|
700
705
|
const orphanedTmps = await listTablesLike(db, "ec_%_i18n_tmp");
|
|
701
706
|
for (const tmpName of orphanedTmps) {
|
|
@@ -812,7 +817,7 @@ async function downPostgres(db) {
|
|
|
812
817
|
await sql`ALTER TABLE ${sql.ref(t)} DROP COLUMN translation_group`.execute(db);
|
|
813
818
|
}
|
|
814
819
|
}
|
|
815
|
-
async function down$
|
|
820
|
+
async function down$26(db) {
|
|
816
821
|
if (!isSqlite(db)) return downPostgres(db);
|
|
817
822
|
await sql`
|
|
818
823
|
ALTER TABLE _dineway_fields
|
|
@@ -919,8 +924,8 @@ async function down$24(db) {
|
|
|
919
924
|
//#endregion
|
|
920
925
|
//#region src/database/migrations/020_collection_url_pattern.ts
|
|
921
926
|
var _020_collection_url_pattern_exports = /* @__PURE__ */ __exportAll({
|
|
922
|
-
down: () => down$
|
|
923
|
-
up: () => up$
|
|
927
|
+
down: () => down$25,
|
|
928
|
+
up: () => up$25
|
|
924
929
|
});
|
|
925
930
|
/**
|
|
926
931
|
* Migration: URL pattern for collections
|
|
@@ -929,13 +934,13 @@ var _020_collection_url_pattern_exports = /* @__PURE__ */ __exportAll({
|
|
|
929
934
|
* can declare its own URL structure (e.g. "/{slug}" for pages, "/blog/{slug}"
|
|
930
935
|
* for posts). Used for menu URL resolution, sitemaps, and path-based lookups.
|
|
931
936
|
*/
|
|
932
|
-
async function up$
|
|
937
|
+
async function up$25(db) {
|
|
933
938
|
await sql`
|
|
934
939
|
ALTER TABLE _dineway_collections
|
|
935
940
|
ADD COLUMN url_pattern TEXT
|
|
936
941
|
`.execute(db);
|
|
937
942
|
}
|
|
938
|
-
async function down$
|
|
943
|
+
async function down$25(db) {
|
|
939
944
|
await sql`
|
|
940
945
|
ALTER TABLE _dineway_collections
|
|
941
946
|
DROP COLUMN url_pattern
|
|
@@ -945,8 +950,8 @@ async function down$23(db) {
|
|
|
945
950
|
//#endregion
|
|
946
951
|
//#region src/database/migrations/021_remove_section_categories.ts
|
|
947
952
|
var _021_remove_section_categories_exports = /* @__PURE__ */ __exportAll({
|
|
948
|
-
down: () => down$
|
|
949
|
-
up: () => up$
|
|
953
|
+
down: () => down$24,
|
|
954
|
+
up: () => up$24
|
|
950
955
|
});
|
|
951
956
|
/**
|
|
952
957
|
* Migration: Remove section categories
|
|
@@ -955,12 +960,12 @@ var _021_remove_section_categories_exports = /* @__PURE__ */ __exportAll({
|
|
|
955
960
|
* Rather than building the missing UI for a feature with very little need at this stage,
|
|
956
961
|
* we're removing the feature entirely.
|
|
957
962
|
*/
|
|
958
|
-
async function up$
|
|
963
|
+
async function up$24(db) {
|
|
959
964
|
await db.schema.dropIndex("idx_sections_category").ifExists().execute();
|
|
960
965
|
await db.schema.alterTable("_dineway_sections").dropColumn("category_id").execute();
|
|
961
966
|
await db.schema.dropTable("_dineway_section_categories").execute();
|
|
962
967
|
}
|
|
963
|
-
async function down$
|
|
968
|
+
async function down$24(db) {
|
|
964
969
|
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();
|
|
965
970
|
await db.schema.alterTable("_dineway_sections").addColumn("category_id", "text", (col) => col.references("_dineway_section_categories.id").onDelete("set null")).execute();
|
|
966
971
|
await db.schema.createIndex("idx_sections_category").on("_dineway_sections").columns(["category_id"]).execute();
|
|
@@ -969,8 +974,8 @@ async function down$22(db) {
|
|
|
969
974
|
//#endregion
|
|
970
975
|
//#region src/database/migrations/022_marketplace_plugin_state.ts
|
|
971
976
|
var _022_marketplace_plugin_state_exports = /* @__PURE__ */ __exportAll({
|
|
972
|
-
down: () => down$
|
|
973
|
-
up: () => up$
|
|
977
|
+
down: () => down$23,
|
|
978
|
+
up: () => up$23
|
|
974
979
|
});
|
|
975
980
|
/**
|
|
976
981
|
* Migration: Add marketplace fields to _plugin_state
|
|
@@ -979,7 +984,7 @@ var _022_marketplace_plugin_state_exports = /* @__PURE__ */ __exportAll({
|
|
|
979
984
|
* whether a plugin was installed from config or marketplace,
|
|
980
985
|
* and which marketplace version is installed.
|
|
981
986
|
*/
|
|
982
|
-
async function up$
|
|
987
|
+
async function up$23(db) {
|
|
983
988
|
await sql`
|
|
984
989
|
ALTER TABLE _plugin_state
|
|
985
990
|
ADD COLUMN source TEXT NOT NULL DEFAULT 'config'
|
|
@@ -994,7 +999,7 @@ async function up$21(db) {
|
|
|
994
999
|
WHERE source = 'marketplace'
|
|
995
1000
|
`.execute(db);
|
|
996
1001
|
}
|
|
997
|
-
async function down$
|
|
1002
|
+
async function down$23(db) {
|
|
998
1003
|
await sql`
|
|
999
1004
|
DROP INDEX IF EXISTS idx_plugin_state_source
|
|
1000
1005
|
`.execute(db);
|
|
@@ -1011,8 +1016,8 @@ async function down$21(db) {
|
|
|
1011
1016
|
//#endregion
|
|
1012
1017
|
//#region src/database/migrations/023_plugin_metadata.ts
|
|
1013
1018
|
var _023_plugin_metadata_exports = /* @__PURE__ */ __exportAll({
|
|
1014
|
-
down: () => down$
|
|
1015
|
-
up: () => up$
|
|
1019
|
+
down: () => down$22,
|
|
1020
|
+
up: () => up$22
|
|
1016
1021
|
});
|
|
1017
1022
|
/**
|
|
1018
1023
|
* Migration: Add display metadata to _plugin_state
|
|
@@ -1021,7 +1026,7 @@ var _023_plugin_metadata_exports = /* @__PURE__ */ __exportAll({
|
|
|
1021
1026
|
* so the admin UI can show meaningful info without re-fetching
|
|
1022
1027
|
* from the marketplace on every page load.
|
|
1023
1028
|
*/
|
|
1024
|
-
async function up$
|
|
1029
|
+
async function up$22(db) {
|
|
1025
1030
|
await sql`
|
|
1026
1031
|
ALTER TABLE _plugin_state
|
|
1027
1032
|
ADD COLUMN display_name TEXT
|
|
@@ -1031,7 +1036,7 @@ async function up$20(db) {
|
|
|
1031
1036
|
ADD COLUMN description TEXT
|
|
1032
1037
|
`.execute(db);
|
|
1033
1038
|
}
|
|
1034
|
-
async function down$
|
|
1039
|
+
async function down$22(db) {
|
|
1035
1040
|
await sql`
|
|
1036
1041
|
ALTER TABLE _plugin_state
|
|
1037
1042
|
DROP COLUMN description
|
|
@@ -1045,8 +1050,8 @@ async function down$20(db) {
|
|
|
1045
1050
|
//#endregion
|
|
1046
1051
|
//#region src/database/migrations/024_media_placeholders.ts
|
|
1047
1052
|
var _024_media_placeholders_exports = /* @__PURE__ */ __exportAll({
|
|
1048
|
-
down: () => down$
|
|
1049
|
-
up: () => up$
|
|
1053
|
+
down: () => down$21,
|
|
1054
|
+
up: () => up$21
|
|
1050
1055
|
});
|
|
1051
1056
|
/**
|
|
1052
1057
|
* Migration: Add placeholder columns to media table
|
|
@@ -1054,7 +1059,7 @@ var _024_media_placeholders_exports = /* @__PURE__ */ __exportAll({
|
|
|
1054
1059
|
* Stores blurhash and dominant_color for LQIP (Low Quality Image Placeholder)
|
|
1055
1060
|
* support. Generated at upload time from image pixel data.
|
|
1056
1061
|
*/
|
|
1057
|
-
async function up$
|
|
1062
|
+
async function up$21(db) {
|
|
1058
1063
|
await sql`
|
|
1059
1064
|
ALTER TABLE media
|
|
1060
1065
|
ADD COLUMN blurhash TEXT
|
|
@@ -1064,7 +1069,7 @@ async function up$19(db) {
|
|
|
1064
1069
|
ADD COLUMN dominant_color TEXT
|
|
1065
1070
|
`.execute(db);
|
|
1066
1071
|
}
|
|
1067
|
-
async function down$
|
|
1072
|
+
async function down$21(db) {
|
|
1068
1073
|
await sql`
|
|
1069
1074
|
ALTER TABLE media
|
|
1070
1075
|
DROP COLUMN dominant_color
|
|
@@ -1078,8 +1083,8 @@ async function down$19(db) {
|
|
|
1078
1083
|
//#endregion
|
|
1079
1084
|
//#region src/database/migrations/025_oauth_clients.ts
|
|
1080
1085
|
var _025_oauth_clients_exports = /* @__PURE__ */ __exportAll({
|
|
1081
|
-
down: () => down$
|
|
1082
|
-
up: () => up$
|
|
1086
|
+
down: () => down$20,
|
|
1087
|
+
up: () => up$20
|
|
1083
1088
|
});
|
|
1084
1089
|
/**
|
|
1085
1090
|
* Migration: Create OAuth clients table
|
|
@@ -1090,18 +1095,18 @@ var _025_oauth_clients_exports = /* @__PURE__ */ __exportAll({
|
|
|
1090
1095
|
* Each client has a set of pre-registered redirect URIs (JSON array).
|
|
1091
1096
|
* The authorize endpoint rejects any redirect_uri not in the client's list.
|
|
1092
1097
|
*/
|
|
1093
|
-
async function up$
|
|
1098
|
+
async function up$20(db) {
|
|
1094
1099
|
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(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp(db))).execute();
|
|
1095
1100
|
}
|
|
1096
|
-
async function down$
|
|
1101
|
+
async function down$20(db) {
|
|
1097
1102
|
await db.schema.dropTable("_dineway_oauth_clients").execute();
|
|
1098
1103
|
}
|
|
1099
1104
|
|
|
1100
1105
|
//#endregion
|
|
1101
1106
|
//#region src/database/migrations/026_cron_tasks.ts
|
|
1102
1107
|
var _026_cron_tasks_exports = /* @__PURE__ */ __exportAll({
|
|
1103
|
-
down: () => down$
|
|
1104
|
-
up: () => up$
|
|
1108
|
+
down: () => down$19,
|
|
1109
|
+
up: () => up$19
|
|
1105
1110
|
});
|
|
1106
1111
|
/**
|
|
1107
1112
|
* Migration: Create cron tasks table for plugin scheduled tasks.
|
|
@@ -1112,7 +1117,7 @@ var _026_cron_tasks_exports = /* @__PURE__ */ __exportAll({
|
|
|
1112
1117
|
* The `next_run_at` + `status` + `enabled` index drives the "find overdue
|
|
1113
1118
|
* tasks" query used by CronExecutor.tick().
|
|
1114
1119
|
*/
|
|
1115
|
-
async function up$
|
|
1120
|
+
async function up$19(db) {
|
|
1116
1121
|
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(db))).addUniqueConstraint("uq_cron_tasks_plugin_task", ["plugin_id", "task_name"]).execute();
|
|
1117
1122
|
await db.schema.createIndex("idx_cron_tasks_due").on("_dineway_cron_tasks").columns([
|
|
1118
1123
|
"enabled",
|
|
@@ -1121,17 +1126,17 @@ async function up$17(db) {
|
|
|
1121
1126
|
]).execute();
|
|
1122
1127
|
await db.schema.createIndex("idx_cron_tasks_plugin").on("_dineway_cron_tasks").column("plugin_id").execute();
|
|
1123
1128
|
}
|
|
1124
|
-
async function down$
|
|
1129
|
+
async function down$19(db) {
|
|
1125
1130
|
await db.schema.dropTable("_dineway_cron_tasks").execute();
|
|
1126
1131
|
}
|
|
1127
1132
|
|
|
1128
1133
|
//#endregion
|
|
1129
1134
|
//#region src/database/migrations/027_comments.ts
|
|
1130
1135
|
var _027_comments_exports = /* @__PURE__ */ __exportAll({
|
|
1131
|
-
down: () => down$
|
|
1132
|
-
up: () => up$
|
|
1136
|
+
down: () => down$18,
|
|
1137
|
+
up: () => up$18
|
|
1133
1138
|
});
|
|
1134
|
-
async function up$
|
|
1139
|
+
async function up$18(db) {
|
|
1135
1140
|
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(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp(db))).execute();
|
|
1136
1141
|
await db.schema.createIndex("idx_comments_content").on("_dineway_comments").columns([
|
|
1137
1142
|
"collection",
|
|
@@ -1147,30 +1152,30 @@ async function up$16(db) {
|
|
|
1147
1152
|
await db.schema.alterTable("_dineway_collections").addColumn("comments_closed_after_days", "integer", (col) => col.defaultTo(90)).execute();
|
|
1148
1153
|
await db.schema.alterTable("_dineway_collections").addColumn("comments_auto_approve_users", "integer", (col) => col.defaultTo(1)).execute();
|
|
1149
1154
|
}
|
|
1150
|
-
async function down$
|
|
1155
|
+
async function down$18(db) {
|
|
1151
1156
|
await db.schema.dropTable("_dineway_comments").execute();
|
|
1152
1157
|
}
|
|
1153
1158
|
|
|
1154
1159
|
//#endregion
|
|
1155
1160
|
//#region src/database/migrations/028_drop_author_url.ts
|
|
1156
1161
|
var _028_drop_author_url_exports = /* @__PURE__ */ __exportAll({
|
|
1157
|
-
down: () => down$
|
|
1158
|
-
up: () => up$
|
|
1162
|
+
down: () => down$17,
|
|
1163
|
+
up: () => up$17
|
|
1159
1164
|
});
|
|
1160
|
-
async function up$
|
|
1165
|
+
async function up$17(db) {
|
|
1161
1166
|
await sql`ALTER TABLE _dineway_comments DROP COLUMN author_url`.execute(db);
|
|
1162
1167
|
}
|
|
1163
|
-
async function down$
|
|
1168
|
+
async function down$17(db) {
|
|
1164
1169
|
await db.schema.alterTable("_dineway_comments").addColumn("author_url", "text").execute();
|
|
1165
1170
|
}
|
|
1166
1171
|
|
|
1167
1172
|
//#endregion
|
|
1168
1173
|
//#region src/database/migrations/029_redirects.ts
|
|
1169
1174
|
var _029_redirects_exports = /* @__PURE__ */ __exportAll({
|
|
1170
|
-
down: () => down$
|
|
1171
|
-
up: () => up$
|
|
1175
|
+
down: () => down$16,
|
|
1176
|
+
up: () => up$16
|
|
1172
1177
|
});
|
|
1173
|
-
async function up$
|
|
1178
|
+
async function up$16(db) {
|
|
1174
1179
|
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(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp(db))).execute();
|
|
1175
1180
|
await db.schema.createIndex("idx_redirects_source").on("_dineway_redirects").column("source").execute();
|
|
1176
1181
|
await db.schema.createIndex("idx_redirects_enabled").on("_dineway_redirects").column("enabled").execute();
|
|
@@ -1179,7 +1184,7 @@ async function up$14(db) {
|
|
|
1179
1184
|
await db.schema.createIndex("idx_404_log_path").on("_dineway_404_log").column("path").execute();
|
|
1180
1185
|
await db.schema.createIndex("idx_404_log_created").on("_dineway_404_log").column("created_at").execute();
|
|
1181
1186
|
}
|
|
1182
|
-
async function down$
|
|
1187
|
+
async function down$16(db) {
|
|
1183
1188
|
await db.schema.dropTable("_dineway_404_log").execute();
|
|
1184
1189
|
await db.schema.dropTable("_dineway_redirects").execute();
|
|
1185
1190
|
}
|
|
@@ -1187,8 +1192,8 @@ async function down$14(db) {
|
|
|
1187
1192
|
//#endregion
|
|
1188
1193
|
//#region src/database/migrations/030_widen_scheduled_index.ts
|
|
1189
1194
|
var _030_widen_scheduled_index_exports = /* @__PURE__ */ __exportAll({
|
|
1190
|
-
down: () => down$
|
|
1191
|
-
up: () => up$
|
|
1195
|
+
down: () => down$15,
|
|
1196
|
+
up: () => up$15
|
|
1192
1197
|
});
|
|
1193
1198
|
/**
|
|
1194
1199
|
* Migration: Widen scheduled publishing index
|
|
@@ -1197,7 +1202,7 @@ var _030_widen_scheduled_index_exports = /* @__PURE__ */ __exportAll({
|
|
|
1197
1202
|
* Published posts can now have scheduled draft changes, so widen the
|
|
1198
1203
|
* index to cover all rows where scheduled_at IS NOT NULL.
|
|
1199
1204
|
*/
|
|
1200
|
-
async function up$
|
|
1205
|
+
async function up$15(db) {
|
|
1201
1206
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1202
1207
|
for (const tableName of tableNames) {
|
|
1203
1208
|
const table = { name: tableName };
|
|
@@ -1211,7 +1216,7 @@ async function up$13(db) {
|
|
|
1211
1216
|
`.execute(db);
|
|
1212
1217
|
}
|
|
1213
1218
|
}
|
|
1214
|
-
async function down$
|
|
1219
|
+
async function down$15(db) {
|
|
1215
1220
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1216
1221
|
for (const tableName of tableNames) {
|
|
1217
1222
|
const table = { name: tableName };
|
|
@@ -1229,10 +1234,10 @@ async function down$13(db) {
|
|
|
1229
1234
|
//#endregion
|
|
1230
1235
|
//#region src/database/migrations/031_bylines.ts
|
|
1231
1236
|
var _031_bylines_exports = /* @__PURE__ */ __exportAll({
|
|
1232
|
-
down: () => down$
|
|
1233
|
-
up: () => up$
|
|
1237
|
+
down: () => down$14,
|
|
1238
|
+
up: () => up$14
|
|
1234
1239
|
});
|
|
1235
|
-
async function up$
|
|
1240
|
+
async function up$14(db) {
|
|
1236
1241
|
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(db))).addColumn("updated_at", "text", (col) => col.defaultTo(currentTimestamp(db))).execute();
|
|
1237
1242
|
await sql`
|
|
1238
1243
|
CREATE UNIQUE INDEX ${sql.ref("idx_bylines_user_id_unique")}
|
|
@@ -1264,7 +1269,7 @@ async function up$12(db) {
|
|
|
1264
1269
|
`.execute(db);
|
|
1265
1270
|
}
|
|
1266
1271
|
}
|
|
1267
|
-
async function down$
|
|
1272
|
+
async function down$14(db) {
|
|
1268
1273
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1269
1274
|
for (const tableName of tableNames) {
|
|
1270
1275
|
await sql`
|
|
@@ -1282,8 +1287,8 @@ async function down$12(db) {
|
|
|
1282
1287
|
//#endregion
|
|
1283
1288
|
//#region src/database/migrations/032_rate_limits.ts
|
|
1284
1289
|
var _032_rate_limits_exports = /* @__PURE__ */ __exportAll({
|
|
1285
|
-
down: () => down$
|
|
1286
|
-
up: () => up$
|
|
1290
|
+
down: () => down$13,
|
|
1291
|
+
up: () => up$13
|
|
1287
1292
|
});
|
|
1288
1293
|
/**
|
|
1289
1294
|
* Migration: Rate limits table + device code polling tracking.
|
|
@@ -1294,12 +1299,12 @@ var _032_rate_limits_exports = /* @__PURE__ */ __exportAll({
|
|
|
1294
1299
|
* 2. Add last_polled_at column to _dineway_device_codes for
|
|
1295
1300
|
* RFC 8628 slow_down enforcement.
|
|
1296
1301
|
*/
|
|
1297
|
-
async function up$
|
|
1302
|
+
async function up$13(db) {
|
|
1298
1303
|
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();
|
|
1299
1304
|
await db.schema.createIndex("idx_rate_limits_window").on("_dineway_rate_limits").column("window").execute();
|
|
1300
1305
|
await db.schema.alterTable("_dineway_device_codes").addColumn("last_polled_at", "text").execute();
|
|
1301
1306
|
}
|
|
1302
|
-
async function down$
|
|
1307
|
+
async function down$13(db) {
|
|
1303
1308
|
await db.schema.dropTable("_dineway_rate_limits").execute();
|
|
1304
1309
|
await db.schema.alterTable("_dineway_device_codes").dropColumn("last_polled_at").execute();
|
|
1305
1310
|
}
|
|
@@ -1307,8 +1312,8 @@ async function down$11(db) {
|
|
|
1307
1312
|
//#endregion
|
|
1308
1313
|
//#region src/database/migrations/033_optimize_content_indexes.ts
|
|
1309
1314
|
var _033_optimize_content_indexes_exports = /* @__PURE__ */ __exportAll({
|
|
1310
|
-
down: () => down$
|
|
1311
|
-
up: () => up$
|
|
1315
|
+
down: () => down$12,
|
|
1316
|
+
up: () => up$12
|
|
1312
1317
|
});
|
|
1313
1318
|
/**
|
|
1314
1319
|
* Migration: Optimize content table indexes for SQLite-compatible performance
|
|
@@ -1321,7 +1326,7 @@ var _033_optimize_content_indexes_exports = /* @__PURE__ */ __exportAll({
|
|
|
1321
1326
|
*
|
|
1322
1327
|
* Impact: Reduces row reads by 90%+ for admin panel operations on SQLite-compatible adapters.
|
|
1323
1328
|
*/
|
|
1324
|
-
async function up$
|
|
1329
|
+
async function up$12(db) {
|
|
1325
1330
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1326
1331
|
for (const tableName of tableNames) {
|
|
1327
1332
|
const table = { name: tableName };
|
|
@@ -1363,7 +1368,7 @@ async function up$10(db) {
|
|
|
1363
1368
|
WHERE status = 'trash'
|
|
1364
1369
|
`.execute(db);
|
|
1365
1370
|
}
|
|
1366
|
-
async function down$
|
|
1371
|
+
async function down$12(db) {
|
|
1367
1372
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1368
1373
|
for (const tableName of tableNames) {
|
|
1369
1374
|
const table = { name: tableName };
|
|
@@ -1396,10 +1401,10 @@ async function down$10(db) {
|
|
|
1396
1401
|
//#endregion
|
|
1397
1402
|
//#region src/database/migrations/034_published_at_index.ts
|
|
1398
1403
|
var _034_published_at_index_exports = /* @__PURE__ */ __exportAll({
|
|
1399
|
-
down: () => down$
|
|
1400
|
-
up: () => up$
|
|
1404
|
+
down: () => down$11,
|
|
1405
|
+
up: () => up$11
|
|
1401
1406
|
});
|
|
1402
|
-
async function up$
|
|
1407
|
+
async function up$11(db) {
|
|
1403
1408
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1404
1409
|
for (const tableName of tableNames) {
|
|
1405
1410
|
const table = { name: tableName };
|
|
@@ -1409,7 +1414,7 @@ async function up$9(db) {
|
|
|
1409
1414
|
`.execute(db);
|
|
1410
1415
|
}
|
|
1411
1416
|
}
|
|
1412
|
-
async function down$
|
|
1417
|
+
async function down$11(db) {
|
|
1413
1418
|
const tableNames = await listTablesLike(db, "ec_%");
|
|
1414
1419
|
for (const tableName of tableNames) {
|
|
1415
1420
|
const table = { name: tableName };
|
|
@@ -1420,15 +1425,15 @@ async function down$9(db) {
|
|
|
1420
1425
|
//#endregion
|
|
1421
1426
|
//#region src/database/migrations/035_backfill_url_patterns.ts
|
|
1422
1427
|
var _035_backfill_url_patterns_exports = /* @__PURE__ */ __exportAll({
|
|
1423
|
-
down: () => down$
|
|
1424
|
-
up: () => up$
|
|
1428
|
+
down: () => down$10,
|
|
1429
|
+
up: () => up$10
|
|
1425
1430
|
});
|
|
1426
1431
|
/**
|
|
1427
1432
|
* Backfill default URL patterns for the built-in posts and pages collections.
|
|
1428
1433
|
*
|
|
1429
1434
|
* Existing rows keep custom patterns; only missing defaults are filled.
|
|
1430
1435
|
*/
|
|
1431
|
-
async function up$
|
|
1436
|
+
async function up$10(db) {
|
|
1432
1437
|
await sql`
|
|
1433
1438
|
UPDATE _dineway_collections
|
|
1434
1439
|
SET url_pattern = '/posts/{slug}'
|
|
@@ -1440,7 +1445,7 @@ async function up$8(db) {
|
|
|
1440
1445
|
WHERE slug = 'pages' AND url_pattern IS NULL
|
|
1441
1446
|
`.execute(db);
|
|
1442
1447
|
}
|
|
1443
|
-
async function down$
|
|
1448
|
+
async function down$10(db) {
|
|
1444
1449
|
await sql`
|
|
1445
1450
|
UPDATE _dineway_collections
|
|
1446
1451
|
SET url_pattern = NULL
|
|
@@ -1456,8 +1461,8 @@ async function down$8(db) {
|
|
|
1456
1461
|
//#endregion
|
|
1457
1462
|
//#region src/database/migrations/036_activity_log.ts
|
|
1458
1463
|
var _036_activity_log_exports = /* @__PURE__ */ __exportAll({
|
|
1459
|
-
down: () => down$
|
|
1460
|
-
up: () => up$
|
|
1464
|
+
down: () => down$9,
|
|
1465
|
+
up: () => up$9
|
|
1461
1466
|
});
|
|
1462
1467
|
/**
|
|
1463
1468
|
* Site Context Engine activity foundation.
|
|
@@ -1466,7 +1471,7 @@ var _036_activity_log_exports = /* @__PURE__ */ __exportAll({
|
|
|
1466
1471
|
* not a request log. Actor IDs intentionally have no foreign key because the
|
|
1467
1472
|
* actor source can be users, API tokens, or a stable system actor.
|
|
1468
1473
|
*/
|
|
1469
|
-
async function up$
|
|
1474
|
+
async function up$9(db) {
|
|
1470
1475
|
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(db))).execute();
|
|
1471
1476
|
await db.schema.createIndex("idx_dineway_activity_actor").on("_dineway_activity_log").columns([
|
|
1472
1477
|
"actor_type",
|
|
@@ -1493,15 +1498,15 @@ async function up$7(db) {
|
|
|
1493
1498
|
await db.schema.createIndex("idx_dineway_activity_result_status").on("_dineway_activity_log").columns(["result_status", "created_at"]).execute();
|
|
1494
1499
|
await db.schema.createIndex("idx_dineway_activity_created_at").on("_dineway_activity_log").column("created_at").execute();
|
|
1495
1500
|
}
|
|
1496
|
-
async function down$
|
|
1501
|
+
async function down$9(db) {
|
|
1497
1502
|
await db.schema.dropTable("_dineway_activity_log").execute();
|
|
1498
1503
|
}
|
|
1499
1504
|
|
|
1500
1505
|
//#endregion
|
|
1501
1506
|
//#region src/database/migrations/037_context_entries.ts
|
|
1502
1507
|
var _037_context_entries_exports = /* @__PURE__ */ __exportAll({
|
|
1503
|
-
down: () => down$
|
|
1504
|
-
up: () => up$
|
|
1508
|
+
down: () => down$8,
|
|
1509
|
+
up: () => up$8
|
|
1505
1510
|
});
|
|
1506
1511
|
const CONTEXT_TYPE_SQL = [
|
|
1507
1512
|
"brand_voice",
|
|
@@ -1526,7 +1531,7 @@ const CONTEXT_TYPE_SQL = [
|
|
|
1526
1531
|
* marking old entries non-current and linking replacements through
|
|
1527
1532
|
* `supersedes_id`.
|
|
1528
1533
|
*/
|
|
1529
|
-
async function up$
|
|
1534
|
+
async function up$8(db) {
|
|
1530
1535
|
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(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp(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();
|
|
1531
1536
|
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();
|
|
1532
1537
|
await db.schema.createIndex("idx_dineway_context_scope_current").on("_dineway_context_entries").columns([
|
|
@@ -1551,7 +1556,7 @@ async function up$6(db) {
|
|
|
1551
1556
|
await db.schema.createIndex("idx_dineway_context_created_at").on("_dineway_context_entries").column("created_at").execute();
|
|
1552
1557
|
await db.schema.createIndex("idx_dineway_context_tags_tag").on("_dineway_context_tags").columns(["tag", "context_entry_id"]).execute();
|
|
1553
1558
|
}
|
|
1554
|
-
async function down$
|
|
1559
|
+
async function down$8(db) {
|
|
1555
1560
|
await db.schema.dropTable("_dineway_context_tags").execute();
|
|
1556
1561
|
await db.schema.dropTable("_dineway_context_entries").execute();
|
|
1557
1562
|
}
|
|
@@ -1559,8 +1564,8 @@ async function down$6(db) {
|
|
|
1559
1564
|
//#endregion
|
|
1560
1565
|
//#region src/database/migrations/038_review_requests.ts
|
|
1561
1566
|
var _038_review_requests_exports = /* @__PURE__ */ __exportAll({
|
|
1562
|
-
down: () => down$
|
|
1563
|
-
up: () => up$
|
|
1567
|
+
down: () => down$7,
|
|
1568
|
+
up: () => up$7
|
|
1564
1569
|
});
|
|
1565
1570
|
/**
|
|
1566
1571
|
* Lightweight content review requests for Phase 5a.
|
|
@@ -1568,7 +1573,7 @@ var _038_review_requests_exports = /* @__PURE__ */ __exportAll({
|
|
|
1568
1573
|
* Review requests bind human approval to immutable content revision/action
|
|
1569
1574
|
* identifiers so an approval cannot be reused after the draft or action changes.
|
|
1570
1575
|
*/
|
|
1571
|
-
async function up$
|
|
1576
|
+
async function up$7(db) {
|
|
1572
1577
|
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(db))).addColumn("updated_at", "text", (col) => col.notNull().defaultTo(currentTimestamp(db))).addColumn("resolved_at", "text").execute();
|
|
1573
1578
|
await db.schema.createIndex("idx_dineway_review_status_created").on("_dineway_review_requests").columns(["status", "created_at"]).execute();
|
|
1574
1579
|
await db.schema.createIndex("idx_dineway_review_target").on("_dineway_review_requests").columns([
|
|
@@ -1589,15 +1594,15 @@ async function up$5(db) {
|
|
|
1589
1594
|
]).execute();
|
|
1590
1595
|
await db.schema.createIndex("idx_dineway_review_resolved_at").on("_dineway_review_requests").column("resolved_at").execute();
|
|
1591
1596
|
}
|
|
1592
|
-
async function down$
|
|
1597
|
+
async function down$7(db) {
|
|
1593
1598
|
await db.schema.dropTable("_dineway_review_requests").execute();
|
|
1594
1599
|
}
|
|
1595
1600
|
|
|
1596
1601
|
//#endregion
|
|
1597
1602
|
//#region src/database/migrations/039_entity_aliases.ts
|
|
1598
1603
|
var _039_entity_aliases_exports = /* @__PURE__ */ __exportAll({
|
|
1599
|
-
down: () => down$
|
|
1600
|
-
up: () => up$
|
|
1604
|
+
down: () => down$6,
|
|
1605
|
+
up: () => up$6
|
|
1601
1606
|
});
|
|
1602
1607
|
const ENTITY_ALIAS_TYPES = [
|
|
1603
1608
|
"content",
|
|
@@ -1612,7 +1617,7 @@ const ENTITY_ALIAS_TYPES = [
|
|
|
1612
1617
|
* This replaces CRMy's PostgreSQL-specific alias arrays with a normalized
|
|
1613
1618
|
* mapping table that works across SQLite/libSQL and PostgreSQL.
|
|
1614
1619
|
*/
|
|
1615
|
-
async function up$
|
|
1620
|
+
async function up$6(db) {
|
|
1616
1621
|
const entityTypesSql = sql.join(ENTITY_ALIAS_TYPES.map((value) => sql.lit(value)), sql`, `);
|
|
1617
1622
|
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(db))).execute();
|
|
1618
1623
|
await db.schema.createIndex("idx_dineway_entity_alias_lookup").on("_dineway_entity_aliases").columns(["entity_type", "normalized_alias"]).execute();
|
|
@@ -1629,15 +1634,15 @@ async function up$4(db) {
|
|
|
1629
1634
|
"normalized_alias"
|
|
1630
1635
|
]).unique().execute();
|
|
1631
1636
|
}
|
|
1632
|
-
async function down$
|
|
1637
|
+
async function down$6(db) {
|
|
1633
1638
|
await db.schema.dropTable("_dineway_entity_aliases").execute();
|
|
1634
1639
|
}
|
|
1635
1640
|
|
|
1636
1641
|
//#endregion
|
|
1637
1642
|
//#region src/database/migrations/040_handoff_snapshots.ts
|
|
1638
1643
|
var _040_handoff_snapshots_exports = /* @__PURE__ */ __exportAll({
|
|
1639
|
-
down: () => down$
|
|
1640
|
-
up: () => up$
|
|
1644
|
+
down: () => down$5,
|
|
1645
|
+
up: () => up$5
|
|
1641
1646
|
});
|
|
1642
1647
|
const ACTOR_TYPES$2 = [
|
|
1643
1648
|
"user",
|
|
@@ -1650,7 +1655,7 @@ const HANDOFF_KINDS = [
|
|
|
1650
1655
|
"assignment"
|
|
1651
1656
|
];
|
|
1652
1657
|
const REFERENCE_TYPES = ["review_request", "assignment"];
|
|
1653
|
-
async function up$
|
|
1658
|
+
async function up$5(db) {
|
|
1654
1659
|
const actorTypesSql = sql.join(ACTOR_TYPES$2.map((value) => sql.lit(value)), sql`, `);
|
|
1655
1660
|
const handoffKindsSql = sql.join(HANDOFF_KINDS.map((value) => sql.lit(value)), sql`, `);
|
|
1656
1661
|
const referenceTypesSql = sql.join(REFERENCE_TYPES.map((value) => sql.lit(value)), sql`, `);
|
|
@@ -1664,15 +1669,15 @@ async function up$3(db) {
|
|
|
1664
1669
|
await db.schema.createIndex("idx_dineway_handoff_kind_created").on("_dineway_handoff_snapshots").columns(["handoff_kind", "created_at"]).execute();
|
|
1665
1670
|
await db.schema.createIndex("idx_dineway_handoff_reference").on("_dineway_handoff_snapshots").columns(["reference_type", "reference_id"]).execute();
|
|
1666
1671
|
}
|
|
1667
|
-
async function down$
|
|
1672
|
+
async function down$5(db) {
|
|
1668
1673
|
await db.schema.dropTable("_dineway_handoff_snapshots").execute();
|
|
1669
1674
|
}
|
|
1670
1675
|
|
|
1671
1676
|
//#endregion
|
|
1672
1677
|
//#region src/database/migrations/041_assignments.ts
|
|
1673
1678
|
var _041_assignments_exports = /* @__PURE__ */ __exportAll({
|
|
1674
|
-
down: () => down$
|
|
1675
|
-
up: () => up$
|
|
1679
|
+
down: () => down$4,
|
|
1680
|
+
up: () => up$4
|
|
1676
1681
|
});
|
|
1677
1682
|
const ACTOR_TYPES$1 = [
|
|
1678
1683
|
"user",
|
|
@@ -1694,7 +1699,7 @@ const ASSIGNMENT_PRIORITIES = [
|
|
|
1694
1699
|
"high",
|
|
1695
1700
|
"urgent"
|
|
1696
1701
|
];
|
|
1697
|
-
async function up$
|
|
1702
|
+
async function up$4(db) {
|
|
1698
1703
|
const actorTypesSql = sql.join(ACTOR_TYPES$1.map((value) => sql.lit(value)), sql`, `);
|
|
1699
1704
|
const statusesSql = sql.join(ASSIGNMENT_STATUSES.map((value) => sql.lit(value)), sql`, `);
|
|
1700
1705
|
const prioritiesSql = sql.join(ASSIGNMENT_PRIORITIES.map((value) => sql.lit(value)), sql`, `);
|
|
@@ -1726,15 +1731,15 @@ async function up$2(db) {
|
|
|
1726
1731
|
await db.schema.createIndex("idx_dineway_assignment_due_at").on("_dineway_assignments").column("due_at").execute();
|
|
1727
1732
|
await db.schema.createIndex("idx_dineway_assignment_handoff").on("_dineway_assignments").column("related_handoff_snapshot_id").execute();
|
|
1728
1733
|
}
|
|
1729
|
-
async function down$
|
|
1734
|
+
async function down$4(db) {
|
|
1730
1735
|
await db.schema.dropTable("_dineway_assignments").execute();
|
|
1731
1736
|
}
|
|
1732
1737
|
|
|
1733
1738
|
//#endregion
|
|
1734
1739
|
//#region src/database/migrations/042_hitl_requests.ts
|
|
1735
1740
|
var _042_hitl_requests_exports = /* @__PURE__ */ __exportAll({
|
|
1736
|
-
down: () => down$
|
|
1737
|
-
up: () => up$
|
|
1741
|
+
down: () => down$3,
|
|
1742
|
+
up: () => up$3
|
|
1738
1743
|
});
|
|
1739
1744
|
const ACTOR_TYPES = [
|
|
1740
1745
|
"user",
|
|
@@ -1752,7 +1757,7 @@ const HITL_PRIORITIES = [
|
|
|
1752
1757
|
"high",
|
|
1753
1758
|
"urgent"
|
|
1754
1759
|
];
|
|
1755
|
-
async function up$
|
|
1760
|
+
async function up$3(db) {
|
|
1756
1761
|
const actorTypesSql = sql.join(ACTOR_TYPES.map((value) => sql.lit(value)), sql`, `);
|
|
1757
1762
|
const statusesSql = sql.join(HITL_STATUSES.map((value) => sql.lit(value)), sql`, `);
|
|
1758
1763
|
const prioritiesSql = sql.join(HITL_PRIORITIES.map((value) => sql.lit(value)), sql`, `);
|
|
@@ -1787,7 +1792,7 @@ async function up$1(db) {
|
|
|
1787
1792
|
await db.schema.createIndex("idx_dineway_hitl_sla_due_at").on("_dineway_hitl_requests").column("sla_due_at").execute();
|
|
1788
1793
|
await db.schema.createIndex("idx_dineway_assignment_hitl").on("_dineway_assignments").column("related_hitl_request_id").execute();
|
|
1789
1794
|
}
|
|
1790
|
-
async function down$
|
|
1795
|
+
async function down$3(db) {
|
|
1791
1796
|
await db.schema.dropIndex("idx_dineway_assignment_hitl").execute();
|
|
1792
1797
|
await db.schema.alterTable("_dineway_assignments").dropColumn("related_hitl_request_id").execute();
|
|
1793
1798
|
await db.schema.dropTable("_dineway_hitl_requests").execute();
|
|
@@ -1796,8 +1801,8 @@ async function down$1(db) {
|
|
|
1796
1801
|
//#endregion
|
|
1797
1802
|
//#region src/database/migrations/043_bounded_404_log.ts
|
|
1798
1803
|
var _043_bounded_404_log_exports = /* @__PURE__ */ __exportAll({
|
|
1799
|
-
down: () => down,
|
|
1800
|
-
up: () => up
|
|
1804
|
+
down: () => down$2,
|
|
1805
|
+
up: () => up$2
|
|
1801
1806
|
});
|
|
1802
1807
|
/**
|
|
1803
1808
|
* Migration: Bounded 404 logging
|
|
@@ -1806,7 +1811,7 @@ var _043_bounded_404_log_exports = /* @__PURE__ */ __exportAll({
|
|
|
1806
1811
|
* Previously every 404 inserted a new row, so a requester could grow the
|
|
1807
1812
|
* table without bound by hitting unique URLs.
|
|
1808
1813
|
*/
|
|
1809
|
-
async function up(db) {
|
|
1814
|
+
async function up$2(db) {
|
|
1810
1815
|
await db.schema.alterTable("_dineway_404_log").addColumn("hits", "integer", (col) => col.notNull().defaultTo(1)).execute();
|
|
1811
1816
|
await db.schema.alterTable("_dineway_404_log").addColumn("last_seen_at", "text").execute();
|
|
1812
1817
|
await sql`
|
|
@@ -1852,7 +1857,7 @@ async function up(db) {
|
|
|
1852
1857
|
await db.schema.dropIndex("idx_404_log_path").execute();
|
|
1853
1858
|
await db.schema.createIndex("idx_404_log_last_seen").on("_dineway_404_log").column("last_seen_at").execute();
|
|
1854
1859
|
}
|
|
1855
|
-
async function down(db) {
|
|
1860
|
+
async function down$2(db) {
|
|
1856
1861
|
await db.schema.dropIndex("idx_404_log_last_seen").execute();
|
|
1857
1862
|
await db.schema.dropIndex("idx_404_log_path_unique").execute();
|
|
1858
1863
|
await db.schema.createIndex("idx_404_log_path").on("_dineway_404_log").column("path").execute();
|
|
@@ -1860,6 +1865,314 @@ async function down(db) {
|
|
|
1860
1865
|
await db.schema.alterTable("_dineway_404_log").dropColumn("hits").execute();
|
|
1861
1866
|
}
|
|
1862
1867
|
|
|
1868
|
+
//#endregion
|
|
1869
|
+
//#region src/database/migrations/044_credential_algorithm.ts
|
|
1870
|
+
var _044_credential_algorithm_exports = /* @__PURE__ */ __exportAll({
|
|
1871
|
+
down: () => down$1,
|
|
1872
|
+
up: () => up$1
|
|
1873
|
+
});
|
|
1874
|
+
async function up$1(db) {
|
|
1875
|
+
if (!await columnExists(db, "credentials", "algorithm")) await db.schema.alterTable("credentials").addColumn("algorithm", "integer", (col) => col.notNull().defaultTo(-7)).execute();
|
|
1876
|
+
}
|
|
1877
|
+
async function down$1(db) {
|
|
1878
|
+
if (await columnExists(db, "credentials", "algorithm")) await db.schema.alterTable("credentials").dropColumn("algorithm").execute();
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
//#endregion
|
|
1882
|
+
//#region src/database/migrations/045_i18n_menus_and_taxonomies.ts
|
|
1883
|
+
var _045_i18n_menus_and_taxonomies_exports = /* @__PURE__ */ __exportAll({
|
|
1884
|
+
down: () => down,
|
|
1885
|
+
up: () => up
|
|
1886
|
+
});
|
|
1887
|
+
/**
|
|
1888
|
+
* i18n for menus + taxonomies. Adds `locale` + `translation_group` to system
|
|
1889
|
+
* tables and stores translation_groups (not row ids) in
|
|
1890
|
+
* `_dineway_menu_items.reference_id` and `content_taxonomies.taxonomy_id`.
|
|
1891
|
+
* Backfill locale and column DEFAULTs use the site's configured defaultLocale.
|
|
1892
|
+
*/
|
|
1893
|
+
function getDefaultLocale() {
|
|
1894
|
+
return getI18nConfig()?.defaultLocale ?? "en";
|
|
1895
|
+
}
|
|
1896
|
+
async function up(db) {
|
|
1897
|
+
const defaultLocale = getDefaultLocale();
|
|
1898
|
+
if (isSqlite(db)) {
|
|
1899
|
+
await sql.raw(`PRAGMA foreign_keys = OFF`).execute(db);
|
|
1900
|
+
try {
|
|
1901
|
+
await rebuildMenus(db, defaultLocale);
|
|
1902
|
+
await addItemColumns(db, defaultLocale);
|
|
1903
|
+
await rebuildTaxonomies(db, defaultLocale);
|
|
1904
|
+
await rebuildTaxonomyDefs(db, defaultLocale);
|
|
1905
|
+
await rebuildContentTaxonomies(db);
|
|
1906
|
+
await remapMenuItemRefs(db);
|
|
1907
|
+
} finally {
|
|
1908
|
+
await sql.raw(`PRAGMA foreign_keys = ON`).execute(db);
|
|
1909
|
+
}
|
|
1910
|
+
return;
|
|
1911
|
+
}
|
|
1912
|
+
await pgWiden(db, "_dineway_menus", ["name"], ["name", "locale"], defaultLocale);
|
|
1913
|
+
await pgWiden(db, "_dineway_menu_items", null, null, defaultLocale);
|
|
1914
|
+
await pgWiden(db, "taxonomies", ["name", "slug"], [
|
|
1915
|
+
"name",
|
|
1916
|
+
"slug",
|
|
1917
|
+
"locale"
|
|
1918
|
+
], defaultLocale);
|
|
1919
|
+
await pgWiden(db, "_dineway_taxonomy_defs", ["name"], ["name", "locale"], defaultLocale);
|
|
1920
|
+
await pgRemapContentTaxonomies(db);
|
|
1921
|
+
await remapMenuItemRefs(db);
|
|
1922
|
+
}
|
|
1923
|
+
async function rebuildMenus(db, defaultLocale) {
|
|
1924
|
+
if (await hasColumn(db, "_dineway_menus", "locale")) return;
|
|
1925
|
+
await sql.raw(`DROP TABLE IF EXISTS "_dineway_menus_new"`).execute(db);
|
|
1926
|
+
await db.schema.createTable("_dineway_menus_new").addColumn("id", "text", (c) => c.primaryKey()).addColumn("name", "text", (c) => c.notNull()).addColumn("label", "text", (c) => c.notNull()).addColumn("created_at", "text", (c) => c.defaultTo(currentTimestamp(db))).addColumn("updated_at", "text", (c) => c.defaultTo(currentTimestamp(db))).addColumn("locale", "text", (c) => c.notNull().defaultTo(defaultLocale)).addColumn("translation_group", "text").addUniqueConstraint("_dineway_menus_name_locale_unique", ["name", "locale"]).execute();
|
|
1927
|
+
await sql`
|
|
1928
|
+
INSERT INTO _dineway_menus_new (id, name, label, created_at, updated_at, locale, translation_group)
|
|
1929
|
+
SELECT id, name, label, created_at, updated_at, ${defaultLocale}, id FROM _dineway_menus
|
|
1930
|
+
`.execute(db);
|
|
1931
|
+
await db.schema.dropTable("_dineway_menus").execute();
|
|
1932
|
+
await sql`ALTER TABLE _dineway_menus_new RENAME TO _dineway_menus`.execute(db);
|
|
1933
|
+
await db.schema.createIndex("idx__dineway_menus_locale").on("_dineway_menus").column("locale").execute();
|
|
1934
|
+
await db.schema.createIndex("idx__dineway_menus_translation_group").on("_dineway_menus").column("translation_group").execute();
|
|
1935
|
+
}
|
|
1936
|
+
async function addItemColumns(db, defaultLocale) {
|
|
1937
|
+
if (await hasColumn(db, "_dineway_menu_items", "locale")) return;
|
|
1938
|
+
await db.schema.alterTable("_dineway_menu_items").addColumn("locale", "text", (c) => c.notNull().defaultTo(defaultLocale)).execute();
|
|
1939
|
+
await db.schema.alterTable("_dineway_menu_items").addColumn("translation_group", "text").execute();
|
|
1940
|
+
await sql`UPDATE _dineway_menu_items SET translation_group = id`.execute(db);
|
|
1941
|
+
await db.schema.createIndex("idx__dineway_menu_items_locale").on("_dineway_menu_items").column("locale").execute();
|
|
1942
|
+
await db.schema.createIndex("idx__dineway_menu_items_translation_group").on("_dineway_menu_items").column("translation_group").execute();
|
|
1943
|
+
}
|
|
1944
|
+
async function rebuildTaxonomies(db, defaultLocale) {
|
|
1945
|
+
if (await hasColumn(db, "taxonomies", "locale")) return;
|
|
1946
|
+
await sql.raw(`DROP TABLE IF EXISTS "taxonomies_new"`).execute(db);
|
|
1947
|
+
await sql`DROP INDEX IF EXISTS idx_taxonomies_name`.execute(db);
|
|
1948
|
+
await db.schema.createTable("taxonomies_new").addColumn("id", "text", (c) => c.primaryKey()).addColumn("name", "text", (c) => c.notNull()).addColumn("slug", "text", (c) => c.notNull()).addColumn("label", "text", (c) => c.notNull()).addColumn("parent_id", "text").addColumn("data", "text").addColumn("locale", "text", (c) => c.notNull().defaultTo(defaultLocale)).addColumn("translation_group", "text").addUniqueConstraint("taxonomies_name_slug_locale_unique", [
|
|
1949
|
+
"name",
|
|
1950
|
+
"slug",
|
|
1951
|
+
"locale"
|
|
1952
|
+
]).addForeignKeyConstraint("taxonomies_parent_fk", ["parent_id"], "taxonomies", ["id"], (cb) => cb.onDelete("set null")).execute();
|
|
1953
|
+
await sql`
|
|
1954
|
+
INSERT INTO taxonomies_new (id, name, slug, label, parent_id, data, locale, translation_group)
|
|
1955
|
+
SELECT id, name, slug, label, parent_id, data, ${defaultLocale}, id FROM taxonomies
|
|
1956
|
+
`.execute(db);
|
|
1957
|
+
await db.schema.dropTable("taxonomies").execute();
|
|
1958
|
+
await sql`ALTER TABLE taxonomies_new RENAME TO taxonomies`.execute(db);
|
|
1959
|
+
await db.schema.createIndex("idx_taxonomies_name").on("taxonomies").column("name").execute();
|
|
1960
|
+
await db.schema.createIndex("idx_taxonomies_locale").on("taxonomies").column("locale").execute();
|
|
1961
|
+
await db.schema.createIndex("idx_taxonomies_translation_group").on("taxonomies").column("translation_group").execute();
|
|
1962
|
+
}
|
|
1963
|
+
async function rebuildTaxonomyDefs(db, defaultLocale) {
|
|
1964
|
+
if (await hasColumn(db, "_dineway_taxonomy_defs", "locale")) return;
|
|
1965
|
+
await sql.raw(`DROP TABLE IF EXISTS "_dineway_taxonomy_defs_new"`).execute(db);
|
|
1966
|
+
await db.schema.createTable("_dineway_taxonomy_defs_new").addColumn("id", "text", (c) => c.primaryKey()).addColumn("name", "text", (c) => c.notNull()).addColumn("label", "text", (c) => c.notNull()).addColumn("label_singular", "text").addColumn("hierarchical", "integer", (c) => c.defaultTo(0)).addColumn("collections", "text").addColumn("created_at", "text", (c) => c.defaultTo(currentTimestamp(db))).addColumn("locale", "text", (c) => c.notNull().defaultTo(defaultLocale)).addColumn("translation_group", "text").addUniqueConstraint("_dineway_taxonomy_defs_name_locale_unique", ["name", "locale"]).execute();
|
|
1967
|
+
await sql`
|
|
1968
|
+
INSERT INTO _dineway_taxonomy_defs_new
|
|
1969
|
+
(id, name, label, label_singular, hierarchical, collections, created_at, locale, translation_group)
|
|
1970
|
+
SELECT id, name, label, label_singular, hierarchical, collections, created_at, ${defaultLocale}, id
|
|
1971
|
+
FROM _dineway_taxonomy_defs
|
|
1972
|
+
`.execute(db);
|
|
1973
|
+
await db.schema.dropTable("_dineway_taxonomy_defs").execute();
|
|
1974
|
+
await sql`ALTER TABLE _dineway_taxonomy_defs_new RENAME TO _dineway_taxonomy_defs`.execute(db);
|
|
1975
|
+
await db.schema.createIndex("idx__dineway_taxonomy_defs_locale").on("_dineway_taxonomy_defs").column("locale").execute();
|
|
1976
|
+
await db.schema.createIndex("idx__dineway_taxonomy_defs_translation_group").on("_dineway_taxonomy_defs").column("translation_group").execute();
|
|
1977
|
+
}
|
|
1978
|
+
async function rebuildContentTaxonomies(db) {
|
|
1979
|
+
if ((await sql`PRAGMA foreign_key_list(content_taxonomies)`.execute(db)).rows.length === 0) return;
|
|
1980
|
+
await sql.raw(`DROP TABLE IF EXISTS "content_taxonomies_new"`).execute(db);
|
|
1981
|
+
await db.schema.createTable("content_taxonomies_new").addColumn("collection", "text", (c) => c.notNull()).addColumn("entry_id", "text", (c) => c.notNull()).addColumn("taxonomy_id", "text", (c) => c.notNull()).addPrimaryKeyConstraint("content_taxonomies_pk", [
|
|
1982
|
+
"collection",
|
|
1983
|
+
"entry_id",
|
|
1984
|
+
"taxonomy_id"
|
|
1985
|
+
]).execute();
|
|
1986
|
+
await sql`
|
|
1987
|
+
INSERT OR IGNORE INTO content_taxonomies_new (collection, entry_id, taxonomy_id)
|
|
1988
|
+
SELECT ct.collection, ct.entry_id, COALESCE(
|
|
1989
|
+
(SELECT t.translation_group FROM taxonomies t WHERE t.id = ct.taxonomy_id),
|
|
1990
|
+
ct.taxonomy_id
|
|
1991
|
+
)
|
|
1992
|
+
FROM content_taxonomies ct
|
|
1993
|
+
`.execute(db);
|
|
1994
|
+
await db.schema.dropTable("content_taxonomies").execute();
|
|
1995
|
+
await sql`ALTER TABLE content_taxonomies_new RENAME TO content_taxonomies`.execute(db);
|
|
1996
|
+
await db.schema.createIndex("idx_content_taxonomies_term").on("content_taxonomies").column("taxonomy_id").execute();
|
|
1997
|
+
}
|
|
1998
|
+
async function remapMenuItemRefs(db) {
|
|
1999
|
+
const collections = await sql`SELECT slug FROM _dineway_collections`.execute(db);
|
|
2000
|
+
for (const { slug } of collections.rows) {
|
|
2001
|
+
validateIdentifier(slug, "collection slug");
|
|
2002
|
+
const ec = sql.ref(`ec_${slug}`);
|
|
2003
|
+
await sql`
|
|
2004
|
+
UPDATE _dineway_menu_items SET reference_id = (
|
|
2005
|
+
SELECT translation_group FROM ${ec} WHERE ${ec}.id = _dineway_menu_items.reference_id
|
|
2006
|
+
)
|
|
2007
|
+
WHERE reference_collection = ${slug} AND reference_id IS NOT NULL
|
|
2008
|
+
AND EXISTS (SELECT 1 FROM ${ec} WHERE ${ec}.id = _dineway_menu_items.reference_id)
|
|
2009
|
+
`.execute(db);
|
|
2010
|
+
}
|
|
2011
|
+
await sql`
|
|
2012
|
+
UPDATE _dineway_menu_items SET reference_id = (
|
|
2013
|
+
SELECT translation_group FROM taxonomies WHERE taxonomies.id = _dineway_menu_items.reference_id
|
|
2014
|
+
)
|
|
2015
|
+
WHERE type = 'taxonomy' AND reference_id IS NOT NULL
|
|
2016
|
+
AND EXISTS (SELECT 1 FROM taxonomies WHERE taxonomies.id = _dineway_menu_items.reference_id)
|
|
2017
|
+
`.execute(db);
|
|
2018
|
+
}
|
|
2019
|
+
async function pgWiden(db, table, oldCols, newCols, defaultLocale) {
|
|
2020
|
+
validateSystemIdent(table);
|
|
2021
|
+
const ref = sql.ref(table);
|
|
2022
|
+
await sql`ALTER TABLE ${ref} ADD COLUMN IF NOT EXISTS locale TEXT NOT NULL DEFAULT ${sql.lit(defaultLocale)}`.execute(db);
|
|
2023
|
+
await sql`ALTER TABLE ${ref} ADD COLUMN IF NOT EXISTS translation_group TEXT`.execute(db);
|
|
2024
|
+
await sql`UPDATE ${ref} SET translation_group = id WHERE translation_group IS NULL`.execute(db);
|
|
2025
|
+
await sql`CREATE INDEX IF NOT EXISTS ${sql.ref(`idx_${table}_locale`)} ON ${ref} (locale)`.execute(db);
|
|
2026
|
+
await sql`
|
|
2027
|
+
CREATE INDEX IF NOT EXISTS ${sql.ref(`idx_${table}_translation_group`)} ON ${ref} (translation_group)
|
|
2028
|
+
`.execute(db);
|
|
2029
|
+
if (!oldCols || !newCols) return;
|
|
2030
|
+
for (const c of [...oldCols, ...newCols]) validateSystemIdent(c);
|
|
2031
|
+
const cons = await sql`
|
|
2032
|
+
SELECT conname FROM pg_constraint c
|
|
2033
|
+
WHERE c.conrelid = ${table}::regclass AND c.contype = 'u'
|
|
2034
|
+
AND array_length(c.conkey, 1) = ${oldCols.length}
|
|
2035
|
+
AND (
|
|
2036
|
+
SELECT array_agg(a.attname ORDER BY pos.ord)
|
|
2037
|
+
FROM unnest(c.conkey) WITH ORDINALITY AS pos(attnum, ord)
|
|
2038
|
+
JOIN pg_attribute a ON a.attrelid = c.conrelid AND a.attnum = pos.attnum
|
|
2039
|
+
)::text[] = ${oldCols}::text[]
|
|
2040
|
+
`.execute(db);
|
|
2041
|
+
for (const c of cons.rows) await sql`ALTER TABLE ${ref} DROP CONSTRAINT ${sql.ref(c.conname)}`.execute(db);
|
|
2042
|
+
const cols = sql.join(newCols.map((c) => sql.ref(c)), sql`, `);
|
|
2043
|
+
await sql`
|
|
2044
|
+
ALTER TABLE ${ref}
|
|
2045
|
+
ADD CONSTRAINT ${sql.ref(`${table}_${newCols.join("_")}_unique`)} UNIQUE (${cols})
|
|
2046
|
+
`.execute(db);
|
|
2047
|
+
}
|
|
2048
|
+
async function pgRemapContentTaxonomies(db) {
|
|
2049
|
+
const fks = await sql`
|
|
2050
|
+
SELECT conname FROM pg_constraint
|
|
2051
|
+
WHERE conrelid = 'content_taxonomies'::regclass AND contype = 'f'
|
|
2052
|
+
`.execute(db);
|
|
2053
|
+
for (const c of fks.rows) await sql`ALTER TABLE content_taxonomies DROP CONSTRAINT ${sql.ref(c.conname)}`.execute(db);
|
|
2054
|
+
await sql`
|
|
2055
|
+
UPDATE content_taxonomies SET taxonomy_id = t.translation_group
|
|
2056
|
+
FROM taxonomies t WHERE t.id = content_taxonomies.taxonomy_id
|
|
2057
|
+
`.execute(db);
|
|
2058
|
+
}
|
|
2059
|
+
async function hasColumn(db, table, column) {
|
|
2060
|
+
return (await sql`PRAGMA table_info(${sql.ref(table)})`.execute(db)).rows.some((r) => r.name === column);
|
|
2061
|
+
}
|
|
2062
|
+
const SYSTEM_IDENT = /^[_a-z][a-z0-9_]*$/;
|
|
2063
|
+
function validateSystemIdent(name) {
|
|
2064
|
+
if (!SYSTEM_IDENT.test(name)) throw new Error(`Invalid identifier: "${name}"`);
|
|
2065
|
+
}
|
|
2066
|
+
/**
|
|
2067
|
+
* down() is destructive on multi-locale installs (dropping `locale` collapses
|
|
2068
|
+
* translated rows onto an ambiguous unique key). Refuse to run when any row
|
|
2069
|
+
* sits at a locale other than the configured defaultLocale.
|
|
2070
|
+
*/
|
|
2071
|
+
async function assertSingleLocale(db, defaultLocale) {
|
|
2072
|
+
for (const table of [
|
|
2073
|
+
"_dineway_menus",
|
|
2074
|
+
"_dineway_menu_items",
|
|
2075
|
+
"taxonomies",
|
|
2076
|
+
"_dineway_taxonomy_defs"
|
|
2077
|
+
]) {
|
|
2078
|
+
validateSystemIdent(table);
|
|
2079
|
+
const result = await sql`
|
|
2080
|
+
SELECT COUNT(*) AS count FROM ${sql.ref(table)} WHERE locale != ${defaultLocale}
|
|
2081
|
+
`.execute(db);
|
|
2082
|
+
const count = Number(result.rows[0]?.count ?? 0);
|
|
2083
|
+
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.`);
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
async function down(db) {
|
|
2087
|
+
const defaultLocale = getDefaultLocale();
|
|
2088
|
+
await assertSingleLocale(db, defaultLocale);
|
|
2089
|
+
const widenedTables = [
|
|
2090
|
+
"_dineway_menus",
|
|
2091
|
+
"_dineway_menu_items",
|
|
2092
|
+
"taxonomies",
|
|
2093
|
+
"_dineway_taxonomy_defs"
|
|
2094
|
+
];
|
|
2095
|
+
if (isSqlite(db)) {
|
|
2096
|
+
await sql.raw(`PRAGMA foreign_keys = OFF`).execute(db);
|
|
2097
|
+
try {
|
|
2098
|
+
for (const t of widenedTables) {
|
|
2099
|
+
await sql.raw(`DROP INDEX IF EXISTS idx_${t}_locale`).execute(db);
|
|
2100
|
+
await sql.raw(`DROP INDEX IF EXISTS idx_${t}_translation_group`).execute(db);
|
|
2101
|
+
}
|
|
2102
|
+
await rebuildContentTaxonomiesDown(db, defaultLocale);
|
|
2103
|
+
await rebuildMenusDown(db);
|
|
2104
|
+
await rebuildMenuItemsDown(db);
|
|
2105
|
+
await rebuildTaxonomiesDown(db);
|
|
2106
|
+
await rebuildTaxonomyDefsDown(db);
|
|
2107
|
+
} finally {
|
|
2108
|
+
await sql.raw(`PRAGMA foreign_keys = ON`).execute(db);
|
|
2109
|
+
}
|
|
2110
|
+
return;
|
|
2111
|
+
}
|
|
2112
|
+
for (const t of widenedTables) {
|
|
2113
|
+
await sql.raw(`DROP INDEX IF EXISTS idx_${t}_locale`).execute(db);
|
|
2114
|
+
await sql.raw(`DROP INDEX IF EXISTS idx_${t}_translation_group`).execute(db);
|
|
2115
|
+
await sql.raw(`ALTER TABLE "${t}" DROP COLUMN IF EXISTS locale`).execute(db);
|
|
2116
|
+
await sql.raw(`ALTER TABLE "${t}" DROP COLUMN IF EXISTS translation_group`).execute(db);
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
async function rebuildContentTaxonomiesDown(db, defaultLocale) {
|
|
2120
|
+
await sql.raw(`DROP TABLE IF EXISTS "content_taxonomies_new"`).execute(db);
|
|
2121
|
+
await db.schema.createTable("content_taxonomies_new").addColumn("collection", "text", (c) => c.notNull()).addColumn("entry_id", "text", (c) => c.notNull()).addColumn("taxonomy_id", "text", (c) => c.notNull()).addPrimaryKeyConstraint("content_taxonomies_pk", [
|
|
2122
|
+
"collection",
|
|
2123
|
+
"entry_id",
|
|
2124
|
+
"taxonomy_id"
|
|
2125
|
+
]).addForeignKeyConstraint("content_taxonomies_taxonomy_fk", ["taxonomy_id"], "taxonomies", ["id"], (cb) => cb.onDelete("cascade")).execute();
|
|
2126
|
+
await sql`
|
|
2127
|
+
INSERT OR IGNORE INTO content_taxonomies_new (collection, entry_id, taxonomy_id)
|
|
2128
|
+
SELECT ct.collection, ct.entry_id, COALESCE(
|
|
2129
|
+
(SELECT t.id FROM taxonomies t WHERE t.translation_group = ct.taxonomy_id AND t.locale = ${defaultLocale}),
|
|
2130
|
+
ct.taxonomy_id
|
|
2131
|
+
)
|
|
2132
|
+
FROM content_taxonomies ct
|
|
2133
|
+
`.execute(db);
|
|
2134
|
+
await db.schema.dropTable("content_taxonomies").execute();
|
|
2135
|
+
await sql`ALTER TABLE content_taxonomies_new RENAME TO content_taxonomies`.execute(db);
|
|
2136
|
+
await db.schema.createIndex("idx_content_taxonomies_term").on("content_taxonomies").column("taxonomy_id").execute();
|
|
2137
|
+
}
|
|
2138
|
+
async function rebuildMenusDown(db) {
|
|
2139
|
+
await sql.raw(`DROP TABLE IF EXISTS "_dineway_menus_old"`).execute(db);
|
|
2140
|
+
await db.schema.createTable("_dineway_menus_old").addColumn("id", "text", (c) => c.primaryKey()).addColumn("name", "text", (c) => c.notNull().unique()).addColumn("label", "text", (c) => c.notNull()).addColumn("created_at", "text", (c) => c.defaultTo(currentTimestamp(db))).addColumn("updated_at", "text", (c) => c.defaultTo(currentTimestamp(db))).execute();
|
|
2141
|
+
await sql`
|
|
2142
|
+
INSERT INTO _dineway_menus_old (id, name, label, created_at, updated_at)
|
|
2143
|
+
SELECT id, name, label, created_at, updated_at FROM _dineway_menus
|
|
2144
|
+
`.execute(db);
|
|
2145
|
+
await db.schema.dropTable("_dineway_menus").execute();
|
|
2146
|
+
await sql`ALTER TABLE _dineway_menus_old RENAME TO _dineway_menus`.execute(db);
|
|
2147
|
+
}
|
|
2148
|
+
async function rebuildMenuItemsDown(db) {
|
|
2149
|
+
await sql.raw(`ALTER TABLE _dineway_menu_items DROP COLUMN locale`).execute(db);
|
|
2150
|
+
await sql.raw(`ALTER TABLE _dineway_menu_items DROP COLUMN translation_group`).execute(db);
|
|
2151
|
+
}
|
|
2152
|
+
async function rebuildTaxonomiesDown(db) {
|
|
2153
|
+
await sql.raw(`DROP TABLE IF EXISTS "taxonomies_old"`).execute(db);
|
|
2154
|
+
await db.schema.createTable("taxonomies_old").addColumn("id", "text", (c) => c.primaryKey()).addColumn("name", "text", (c) => c.notNull()).addColumn("slug", "text", (c) => c.notNull()).addColumn("label", "text", (c) => c.notNull()).addColumn("parent_id", "text").addColumn("data", "text").addUniqueConstraint("taxonomies_name_slug_unique", ["name", "slug"]).addForeignKeyConstraint("taxonomies_parent_fk", ["parent_id"], "taxonomies_old", ["id"], (cb) => cb.onDelete("set null")).execute();
|
|
2155
|
+
await sql`
|
|
2156
|
+
INSERT INTO taxonomies_old (id, name, slug, label, parent_id, data)
|
|
2157
|
+
SELECT id, name, slug, label, parent_id, data FROM taxonomies
|
|
2158
|
+
`.execute(db);
|
|
2159
|
+
await db.schema.dropTable("taxonomies").execute();
|
|
2160
|
+
await sql`ALTER TABLE taxonomies_old RENAME TO taxonomies`.execute(db);
|
|
2161
|
+
await db.schema.createIndex("idx_taxonomies_name").on("taxonomies").column("name").execute();
|
|
2162
|
+
}
|
|
2163
|
+
async function rebuildTaxonomyDefsDown(db) {
|
|
2164
|
+
await sql.raw(`DROP TABLE IF EXISTS "_dineway_taxonomy_defs_old"`).execute(db);
|
|
2165
|
+
await db.schema.createTable("_dineway_taxonomy_defs_old").addColumn("id", "text", (c) => c.primaryKey()).addColumn("name", "text", (c) => c.notNull().unique()).addColumn("label", "text", (c) => c.notNull()).addColumn("label_singular", "text").addColumn("hierarchical", "integer", (c) => c.defaultTo(0)).addColumn("collections", "text").addColumn("created_at", "text", (c) => c.defaultTo(currentTimestamp(db))).execute();
|
|
2166
|
+
await sql`
|
|
2167
|
+
INSERT INTO _dineway_taxonomy_defs_old
|
|
2168
|
+
(id, name, label, label_singular, hierarchical, collections, created_at)
|
|
2169
|
+
SELECT id, name, label, label_singular, hierarchical, collections, created_at
|
|
2170
|
+
FROM _dineway_taxonomy_defs
|
|
2171
|
+
`.execute(db);
|
|
2172
|
+
await db.schema.dropTable("_dineway_taxonomy_defs").execute();
|
|
2173
|
+
await sql`ALTER TABLE _dineway_taxonomy_defs_old RENAME TO _dineway_taxonomy_defs`.execute(db);
|
|
2174
|
+
}
|
|
2175
|
+
|
|
1863
2176
|
//#endregion
|
|
1864
2177
|
//#region src/database/migrations/runner.ts
|
|
1865
2178
|
const MIGRATIONS = Object.freeze({
|
|
@@ -1904,7 +2217,9 @@ const MIGRATIONS = Object.freeze({
|
|
|
1904
2217
|
"040_handoff_snapshots": _040_handoff_snapshots_exports,
|
|
1905
2218
|
"041_assignments": _041_assignments_exports,
|
|
1906
2219
|
"042_hitl_requests": _042_hitl_requests_exports,
|
|
1907
|
-
"043_bounded_404_log": _043_bounded_404_log_exports
|
|
2220
|
+
"043_bounded_404_log": _043_bounded_404_log_exports,
|
|
2221
|
+
"044_credential_algorithm": _044_credential_algorithm_exports,
|
|
2222
|
+
"045_i18n_menus_and_taxonomies": _045_i18n_menus_and_taxonomies_exports
|
|
1908
2223
|
});
|
|
1909
2224
|
/** Total number of registered migrations. Exported for use in tests. */
|
|
1910
2225
|
const MIGRATION_COUNT = Object.keys(MIGRATIONS).length;
|