emdash 0.10.0 → 0.11.1

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.
Files changed (148) hide show
  1. package/dist/{apply-UsrFuO7l.mjs → apply-Ded_1vng.mjs} +36 -25
  2. package/dist/{apply-UsrFuO7l.mjs.map → apply-Ded_1vng.mjs.map} +1 -1
  3. package/dist/astro/index.d.mts +5 -5
  4. package/dist/astro/index.mjs +1 -1
  5. package/dist/astro/middleware/auth.d.mts +5 -5
  6. package/dist/astro/middleware/redirect.mjs +2 -2
  7. package/dist/astro/middleware.d.mts.map +1 -1
  8. package/dist/astro/middleware.mjs +83 -33
  9. package/dist/astro/middleware.mjs.map +1 -1
  10. package/dist/astro/types.d.mts +10 -7
  11. package/dist/astro/types.d.mts.map +1 -1
  12. package/dist/{byline-C3vnhIpU.mjs → byline-gFn1r0vA.mjs} +2 -2
  13. package/dist/{byline-C3vnhIpU.mjs.map → byline-gFn1r0vA.mjs.map} +1 -1
  14. package/dist/{bylines-esI7ioa9.mjs → bylines-DTFI8nDM.mjs} +4 -4
  15. package/dist/{bylines-esI7ioa9.mjs.map → bylines-DTFI8nDM.mjs.map} +1 -1
  16. package/dist/{cache-fTzxgMFJ.mjs → cache-BAJbeoZ8.mjs} +2 -2
  17. package/dist/{cache-fTzxgMFJ.mjs.map → cache-BAJbeoZ8.mjs.map} +1 -1
  18. package/dist/{chunks-Da2-b-oA.mjs → chunks-BK1oZS-l.mjs} +2 -2
  19. package/dist/{chunks-Da2-b-oA.mjs.map → chunks-BK1oZS-l.mjs.map} +1 -1
  20. package/dist/cli/index.mjs +102 -27
  21. package/dist/cli/index.mjs.map +1 -1
  22. package/dist/{content-C7G4QXkK.mjs → content-CERxPUN0.mjs} +2 -2
  23. package/dist/{content-C7G4QXkK.mjs.map → content-CERxPUN0.mjs.map} +1 -1
  24. package/dist/database/instrumentation.d.mts +6 -4
  25. package/dist/database/instrumentation.d.mts.map +1 -1
  26. package/dist/database/instrumentation.mjs +19 -7
  27. package/dist/database/instrumentation.mjs.map +1 -1
  28. package/dist/db/index.d.mts +2 -2
  29. package/dist/db/index.mjs +1 -1
  30. package/dist/{index-DjPMOfO0.d.mts → index-BogfvE-z.d.mts} +32 -24
  31. package/dist/index-BogfvE-z.d.mts.map +1 -0
  32. package/dist/index.d.mts +7 -7
  33. package/dist/index.mjs +19 -19
  34. package/dist/{load-sXRuM7Us.mjs → load-DR1VwFXR.mjs} +2 -2
  35. package/dist/{load-sXRuM7Us.mjs.map → load-DR1VwFXR.mjs.map} +1 -1
  36. package/dist/{loader-Bx2_9-5e.mjs → loader-ou_PXAjg.mjs} +2 -2
  37. package/dist/{loader-Bx2_9-5e.mjs.map → loader-ou_PXAjg.mjs.map} +1 -1
  38. package/dist/media/local-runtime.d.mts +5 -5
  39. package/dist/media/local-runtime.mjs +1 -1
  40. package/dist/{media-D8FbNsl0.mjs → media-1fFhub9c.mjs} +21 -9
  41. package/dist/media-1fFhub9c.mjs.map +1 -0
  42. package/dist/page/index.d.mts +2 -2
  43. package/dist/plugins/adapt-sandbox-entry.d.mts +5 -5
  44. package/dist/plugins/adapt-sandbox-entry.mjs +1 -1
  45. package/dist/{query-Bo-msrmu.mjs → query-8c_meo_K.mjs} +10 -10
  46. package/dist/{query-Bo-msrmu.mjs.map → query-8c_meo_K.mjs.map} +1 -1
  47. package/dist/{registry-Beb7wxFc.mjs → registry-Do34mz_P.mjs} +6 -5
  48. package/dist/registry-Do34mz_P.mjs.map +1 -0
  49. package/dist/{request-cache-C-tIpYIw.mjs → request-cache-D4I69LeL.mjs} +6 -2
  50. package/dist/request-cache-D4I69LeL.mjs.map +1 -0
  51. package/dist/request-context.d.mts +27 -1
  52. package/dist/request-context.d.mts.map +1 -1
  53. package/dist/request-context.mjs +16 -3
  54. package/dist/request-context.mjs.map +1 -1
  55. package/dist/{runner-DMnlIkh4.mjs → runner-DIcU2UCC.mjs} +174 -152
  56. package/dist/runner-DIcU2UCC.mjs.map +1 -0
  57. package/dist/{runner-Clwe4Mme.d.mts → runner-Iu3IZSDM.d.mts} +2 -2
  58. package/dist/{runner-Clwe4Mme.d.mts.map → runner-Iu3IZSDM.d.mts.map} +1 -1
  59. package/dist/runtime.d.mts +5 -5
  60. package/dist/runtime.mjs +1 -1
  61. package/dist/{search-DkN-BqsS.mjs → search-DuWhx4NG.mjs} +172 -30
  62. package/dist/search-DuWhx4NG.mjs.map +1 -0
  63. package/dist/seed/index.d.mts +2 -2
  64. package/dist/seed/index.mjs +10 -10
  65. package/dist/{taxonomies-CTtewrSQ.mjs → taxonomies-Bw76xAxo.mjs} +6 -6
  66. package/dist/{taxonomies-CTtewrSQ.mjs.map → taxonomies-Bw76xAxo.mjs.map} +1 -1
  67. package/dist/{taxonomy-DSxx2K2L.mjs → taxonomy-D6NvlKo8.mjs} +3 -3
  68. package/dist/{taxonomy-DSxx2K2L.mjs.map → taxonomy-D6NvlKo8.mjs.map} +1 -1
  69. package/dist/{types-Eg829jj9.mjs → types-56BKbld_.mjs} +1 -1
  70. package/dist/types-56BKbld_.mjs.map +1 -0
  71. package/dist/{types-Dtx1mSMX.d.mts → types-BQx6ZXpR.d.mts} +2 -1
  72. package/dist/types-BQx6ZXpR.d.mts.map +1 -0
  73. package/dist/{types-Dl1fgFjn.d.mts → types-BTe41zL6.d.mts} +4 -3
  74. package/dist/types-BTe41zL6.d.mts.map +1 -0
  75. package/dist/types-DiI8NOG_.mjs +16 -0
  76. package/dist/types-DiI8NOG_.mjs.map +1 -0
  77. package/dist/{types-D19uBYWn.d.mts → types-IjUrQMVe.d.mts} +21 -245
  78. package/dist/types-IjUrQMVe.d.mts.map +1 -0
  79. package/dist/{validate-DHGwADqO.d.mts → validate-CcVQQpmH.d.mts} +7 -3
  80. package/dist/validate-CcVQQpmH.d.mts.map +1 -0
  81. package/dist/{validate-CBIbxM3L.mjs → validate-UK4Ja1uo.mjs} +3 -3
  82. package/dist/{validate-CBIbxM3L.mjs.map → validate-UK4Ja1uo.mjs.map} +1 -1
  83. package/dist/{validation-B1NYiEos.mjs → validation-Vc5DQkJa.mjs} +4 -4
  84. package/dist/{validation-B1NYiEos.mjs.map → validation-Vc5DQkJa.mjs.map} +1 -1
  85. package/dist/version-JjSqv90m.mjs +7 -0
  86. package/dist/{version-CMD42IRC.mjs.map → version-JjSqv90m.mjs.map} +1 -1
  87. package/dist/{zod-generator-BNJDQBSZ.mjs → zod-generator-CHnJUP2l.mjs} +1 -1
  88. package/dist/{zod-generator-BNJDQBSZ.mjs.map → zod-generator-CHnJUP2l.mjs.map} +1 -1
  89. package/package.json +9 -8
  90. package/src/api/errors.ts +5 -0
  91. package/src/api/handlers/content.ts +9 -0
  92. package/src/api/handlers/media-allowlist.ts +40 -0
  93. package/src/api/handlers/media.ts +1 -1
  94. package/src/api/handlers/menus.ts +158 -28
  95. package/src/api/handlers/validate-media-fields.ts +125 -0
  96. package/src/api/schemas/media.ts +23 -3
  97. package/src/api/schemas/schema.ts +11 -2
  98. package/src/astro/middleware.ts +46 -11
  99. package/src/astro/routes/api/content/[collection]/[id]/discard-draft.ts +1 -1
  100. package/src/astro/routes/api/content/[collection]/[id]/duplicate.ts +1 -1
  101. package/src/astro/routes/api/content/[collection]/[id]/permanent.ts +1 -1
  102. package/src/astro/routes/api/content/[collection]/[id]/publish.ts +1 -1
  103. package/src/astro/routes/api/content/[collection]/[id]/restore.ts +1 -1
  104. package/src/astro/routes/api/content/[collection]/[id]/schedule.ts +2 -2
  105. package/src/astro/routes/api/content/[collection]/[id]/unpublish.ts +1 -1
  106. package/src/astro/routes/api/content/[collection]/[id].ts +2 -2
  107. package/src/astro/routes/api/content/[collection]/index.ts +1 -1
  108. package/src/astro/routes/api/media/upload-url.ts +10 -4
  109. package/src/astro/routes/api/media.ts +12 -4
  110. package/src/astro/types.ts +5 -1
  111. package/src/auth/rate-limit.ts +3 -3
  112. package/src/cli/commands/bundle-utils.ts +81 -6
  113. package/src/cli/commands/bundle.ts +18 -15
  114. package/src/cli/commands/export-seed.ts +57 -3
  115. package/src/database/instrumentation.ts +22 -8
  116. package/src/database/migrations/016_api_tokens.ts +18 -3
  117. package/src/database/migrations/037_credential_algorithm.ts +18 -0
  118. package/src/database/migrations/runner.ts +2 -0
  119. package/src/database/repositories/media.ts +40 -10
  120. package/src/database/types.ts +2 -1
  121. package/src/emdash-runtime.ts +16 -3
  122. package/src/fields/file.ts +7 -6
  123. package/src/fields/image.ts +12 -11
  124. package/src/fields/types.ts +3 -0
  125. package/src/index.ts +1 -1
  126. package/src/mcp/server.ts +37 -8
  127. package/src/media/mime.ts +75 -0
  128. package/src/plugins/types.ts +81 -191
  129. package/src/request-cache.ts +6 -2
  130. package/src/request-context.ts +42 -2
  131. package/src/schema/registry.ts +5 -5
  132. package/src/schema/types.ts +3 -2
  133. package/src/seed/apply.ts +25 -8
  134. package/src/seed/types.ts +4 -0
  135. package/dist/index-DjPMOfO0.d.mts.map +0 -1
  136. package/dist/media-D8FbNsl0.mjs.map +0 -1
  137. package/dist/registry-Beb7wxFc.mjs.map +0 -1
  138. package/dist/request-cache-C-tIpYIw.mjs.map +0 -1
  139. package/dist/runner-DMnlIkh4.mjs.map +0 -1
  140. package/dist/search-DkN-BqsS.mjs.map +0 -1
  141. package/dist/types-CoO6mpV3.mjs +0 -68
  142. package/dist/types-CoO6mpV3.mjs.map +0 -1
  143. package/dist/types-D19uBYWn.d.mts.map +0 -1
  144. package/dist/types-Dl1fgFjn.d.mts.map +0 -1
  145. package/dist/types-Dtx1mSMX.d.mts.map +0 -1
  146. package/dist/types-Eg829jj9.mjs.map +0 -1
  147. package/dist/validate-DHGwADqO.d.mts.map +0 -1
  148. package/dist/version-CMD42IRC.mjs +0 -7
@@ -23,8 +23,8 @@ var __exportAll = (all, no_symbols) => {
23
23
  //#endregion
24
24
  //#region src/database/migrations/001_initial.ts
25
25
  var _001_initial_exports = /* @__PURE__ */ __exportAll({
26
- down: () => down$34,
27
- up: () => up$34
26
+ down: () => down$35,
27
+ up: () => up$35
28
28
  });
29
29
  /**
30
30
  * Initial schema migration
@@ -33,7 +33,7 @@ var _001_initial_exports = /* @__PURE__ */ __exportAll({
33
33
  * by the SchemaRegistry when collections are added via the admin UI.
34
34
  * This migration only creates system tables.
35
35
  */
36
- async function up$34(db) {
36
+ async function up$35(db) {
37
37
  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();
38
38
  await db.schema.createIndex("idx_revisions_entry").ifNotExists().on("revisions").columns(["collection", "entry_id"]).execute();
39
39
  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();
@@ -53,7 +53,7 @@ async function up$34(db) {
53
53
  await db.schema.createIndex("idx_audit_action").ifNotExists().on("audit_logs").column("action").execute();
54
54
  await db.schema.createIndex("idx_audit_timestamp").ifNotExists().on("audit_logs").column("timestamp").execute();
55
55
  }
56
- async function down$34(db) {
56
+ async function down$35(db) {
57
57
  await db.schema.dropTable("audit_logs").execute();
58
58
  await db.schema.dropTable("options").execute();
59
59
  await db.schema.dropTable("users").execute();
@@ -66,26 +66,26 @@ async function down$34(db) {
66
66
  //#endregion
67
67
  //#region src/database/migrations/002_media_status.ts
68
68
  var _002_media_status_exports = /* @__PURE__ */ __exportAll({
69
- down: () => down$33,
70
- up: () => up$33
69
+ down: () => down$34,
70
+ up: () => up$34
71
71
  });
72
72
  /**
73
73
  * Add status column to media table for tracking upload state.
74
74
  * Status values: 'pending' | 'ready' | 'failed'
75
75
  */
76
- async function up$33(db) {
76
+ async function up$34(db) {
77
77
  await db.schema.alterTable("media").addColumn("status", "text", (col) => col.notNull().defaultTo("ready")).execute();
78
78
  await db.schema.createIndex("idx_media_status").on("media").column("status").execute();
79
79
  }
80
- async function down$33(db) {
80
+ async function down$34(db) {
81
81
  await db.schema.dropIndex("idx_media_status").execute();
82
82
  }
83
83
 
84
84
  //#endregion
85
85
  //#region src/database/migrations/003_schema_registry.ts
86
86
  var _003_schema_registry_exports = /* @__PURE__ */ __exportAll({
87
- down: () => down$32,
88
- up: () => up$32
87
+ down: () => down$33,
88
+ up: () => up$33
89
89
  });
90
90
  /**
91
91
  * Migration: Schema Registry Tables
@@ -93,14 +93,14 @@ var _003_schema_registry_exports = /* @__PURE__ */ __exportAll({
93
93
  * Creates the schema registry tables that store collection and field definitions.
94
94
  * This enables dynamic schema management where D1 is the source of truth.
95
95
  */
96
- async function up$32(db) {
96
+ async function up$33(db) {
97
97
  await db.schema.createTable("_emdash_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();
98
98
  await db.schema.createTable("_emdash_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"], "_emdash_collections", ["id"], (cb) => cb.onDelete("cascade")).execute();
99
99
  await db.schema.createIndex("idx_fields_collection_slug").on("_emdash_fields").columns(["collection_id", "slug"]).unique().execute();
100
100
  await db.schema.createIndex("idx_fields_collection").on("_emdash_fields").column("collection_id").execute();
101
101
  await db.schema.createIndex("idx_fields_sort").on("_emdash_fields").columns(["collection_id", "sort_order"]).execute();
102
102
  }
103
- async function down$32(db) {
103
+ async function down$33(db) {
104
104
  await db.schema.dropTable("_emdash_fields").execute();
105
105
  await db.schema.dropTable("_emdash_collections").execute();
106
106
  }
@@ -108,8 +108,8 @@ async function down$32(db) {
108
108
  //#endregion
109
109
  //#region src/database/migrations/004_plugins.ts
110
110
  var _004_plugins_exports = /* @__PURE__ */ __exportAll({
111
- down: () => down$31,
112
- up: () => up$31
111
+ down: () => down$32,
112
+ up: () => up$32
113
113
  });
114
114
  /**
115
115
  * Migration: Plugin System Tables
@@ -119,7 +119,7 @@ var _004_plugins_exports = /* @__PURE__ */ __exportAll({
119
119
  *
120
120
  * @see PLUGIN-SYSTEM.md § Plugin Storage
121
121
  */
122
- async function up$31(db) {
122
+ async function up$32(db) {
123
123
  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", [
124
124
  "plugin_id",
125
125
  "collection",
@@ -137,7 +137,7 @@ async function up$31(db) {
137
137
  "index_name"
138
138
  ]).execute();
139
139
  }
140
- async function down$31(db) {
140
+ async function down$32(db) {
141
141
  await db.schema.dropTable("_plugin_indexes").execute();
142
142
  await db.schema.dropTable("_plugin_state").execute();
143
143
  await db.schema.dropTable("_plugin_storage").execute();
@@ -146,8 +146,8 @@ async function down$31(db) {
146
146
  //#endregion
147
147
  //#region src/database/migrations/005_menus.ts
148
148
  var _005_menus_exports = /* @__PURE__ */ __exportAll({
149
- down: () => down$30,
150
- up: () => up$30
149
+ down: () => down$31,
150
+ up: () => up$31
151
151
  });
152
152
  /**
153
153
  * Navigation Menus migration
@@ -155,13 +155,13 @@ var _005_menus_exports = /* @__PURE__ */ __exportAll({
155
155
  * Creates tables for admin-editable navigation menus.
156
156
  * Menu items can reference content entries, taxonomy terms, or custom URLs.
157
157
  */
158
- async function up$30(db) {
158
+ async function up$31(db) {
159
159
  await db.schema.createTable("_emdash_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();
160
160
  await db.schema.createTable("_emdash_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"], "_emdash_menus", ["id"], (cb) => cb.onDelete("cascade")).addForeignKeyConstraint("menu_items_parent_fk", ["parent_id"], "_emdash_menu_items", ["id"], (cb) => cb.onDelete("cascade")).execute();
161
161
  await db.schema.createIndex("idx_menu_items_menu").on("_emdash_menu_items").columns(["menu_id", "sort_order"]).execute();
162
162
  await db.schema.createIndex("idx_menu_items_parent").on("_emdash_menu_items").column("parent_id").execute();
163
163
  }
164
- async function down$30(db) {
164
+ async function down$31(db) {
165
165
  await db.schema.dropTable("_emdash_menu_items").execute();
166
166
  await db.schema.dropTable("_emdash_menus").execute();
167
167
  }
@@ -169,8 +169,8 @@ async function down$30(db) {
169
169
  //#endregion
170
170
  //#region src/database/migrations/006_taxonomy_defs.ts
171
171
  var _006_taxonomy_defs_exports = /* @__PURE__ */ __exportAll({
172
- down: () => down$29,
173
- up: () => up$29
172
+ down: () => down$30,
173
+ up: () => up$30
174
174
  });
175
175
  /**
176
176
  * Taxonomy definitions migration
@@ -178,7 +178,7 @@ var _006_taxonomy_defs_exports = /* @__PURE__ */ __exportAll({
178
178
  * Adds _emdash_taxonomy_defs table to store taxonomy definitions (category, tag, custom)
179
179
  * and seeds default category and tag taxonomies.
180
180
  */
181
- async function up$29(db) {
181
+ async function up$30(db) {
182
182
  await db.schema.createTable("_emdash_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();
183
183
  await db.insertInto("_emdash_taxonomy_defs").values([{
184
184
  id: "taxdef_category",
@@ -196,22 +196,22 @@ async function up$29(db) {
196
196
  collections: JSON.stringify(["posts"])
197
197
  }]).execute();
198
198
  }
199
- async function down$29(db) {
199
+ async function down$30(db) {
200
200
  await db.schema.dropTable("_emdash_taxonomy_defs").execute();
201
201
  }
202
202
 
203
203
  //#endregion
204
204
  //#region src/database/migrations/007_widgets.ts
205
205
  var _007_widgets_exports = /* @__PURE__ */ __exportAll({
206
- down: () => down$28,
207
- up: () => up$28
206
+ down: () => down$29,
207
+ up: () => up$29
208
208
  });
209
- async function up$28(db) {
209
+ async function up$29(db) {
210
210
  await db.schema.createTable("_emdash_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();
211
211
  await db.schema.createTable("_emdash_widgets").addColumn("id", "text", (col) => col.primaryKey()).addColumn("area_id", "text", (col) => col.notNull().references("_emdash_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();
212
212
  await db.schema.createIndex("idx_widgets_area").on("_emdash_widgets").columns(["area_id", "sort_order"]).execute();
213
213
  }
214
- async function down$28(db) {
214
+ async function down$29(db) {
215
215
  await db.schema.dropTable("_emdash_widgets").execute();
216
216
  await db.schema.dropTable("_emdash_widget_areas").execute();
217
217
  }
@@ -219,8 +219,8 @@ async function down$28(db) {
219
219
  //#endregion
220
220
  //#region src/database/migrations/008_auth.ts
221
221
  var _008_auth_exports = /* @__PURE__ */ __exportAll({
222
- down: () => down$27,
223
- up: () => up$27
222
+ down: () => down$28,
223
+ up: () => up$28
224
224
  });
225
225
  /**
226
226
  * Auth migration - passkey-first authentication
@@ -234,7 +234,7 @@ var _008_auth_exports = /* @__PURE__ */ __exportAll({
234
234
  * - Creates oauth_accounts table (external provider links)
235
235
  * - Creates allowed_domains table (self-signup)
236
236
  */
237
- async function up$27(db) {
237
+ async function up$28(db) {
238
238
  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();
239
239
  await sql`
240
240
  INSERT INTO users_new (id, email, name, role, data, created_at, updated_at)
@@ -267,7 +267,7 @@ async function up$27(db) {
267
267
  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();
268
268
  await db.schema.createIndex("idx_auth_challenges_expires").on("auth_challenges").column("expires_at").execute();
269
269
  }
270
- async function down$27(db) {
270
+ async function down$28(db) {
271
271
  await db.schema.dropTable("auth_challenges").execute();
272
272
  await db.schema.dropTable("allowed_domains").execute();
273
273
  await db.schema.dropTable("oauth_accounts").execute();
@@ -300,8 +300,8 @@ async function down$27(db) {
300
300
  //#endregion
301
301
  //#region src/database/migrations/009_user_disabled.ts
302
302
  var _009_user_disabled_exports = /* @__PURE__ */ __exportAll({
303
- down: () => down$26,
304
- up: () => up$26
303
+ down: () => down$27,
304
+ up: () => up$27
305
305
  });
306
306
  /**
307
307
  * User disabled column - for soft-disabling users
@@ -310,19 +310,19 @@ var _009_user_disabled_exports = /* @__PURE__ */ __exportAll({
310
310
  * - Adds disabled column to users table (INTEGER, default 0)
311
311
  * - Disabled users cannot log in
312
312
  */
313
- async function up$26(db) {
313
+ async function up$27(db) {
314
314
  await sql`ALTER TABLE users ADD COLUMN disabled INTEGER NOT NULL DEFAULT 0`.execute(db);
315
315
  await db.schema.createIndex("idx_users_disabled").on("users").column("disabled").execute();
316
316
  }
317
- async function down$26(db) {
317
+ async function down$27(db) {
318
318
  await db.schema.dropIndex("idx_users_disabled").execute();
319
319
  }
320
320
 
321
321
  //#endregion
322
322
  //#region src/database/migrations/011_sections.ts
323
323
  var _011_sections_exports = /* @__PURE__ */ __exportAll({
324
- down: () => down$25,
325
- up: () => up$25
324
+ down: () => down$26,
325
+ up: () => up$26
326
326
  });
327
327
  /**
328
328
  * Migration: Add sections tables and performance indexes
@@ -331,13 +331,13 @@ var _011_sections_exports = /* @__PURE__ */ __exportAll({
331
331
  * They provide a library of pre-built page sections (heroes, CTAs, testimonials, etc.)
332
332
  * that content authors can browse and insert with a single click.
333
333
  */
334
- async function up$25(db) {
334
+ async function up$26(db) {
335
335
  await db.schema.createTable("_emdash_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();
336
336
  await db.schema.createTable("_emdash_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("_emdash_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();
337
337
  await db.schema.createIndex("idx_sections_category").on("_emdash_sections").columns(["category_id"]).execute();
338
338
  await db.schema.createIndex("idx_sections_source").on("_emdash_sections").columns(["source"]).execute();
339
339
  }
340
- async function down$25(db) {
340
+ async function down$26(db) {
341
341
  await db.schema.dropIndex("idx_sections_source").execute();
342
342
  await db.schema.dropIndex("idx_sections_category").execute();
343
343
  await db.schema.dropTable("_emdash_sections").execute();
@@ -347,8 +347,8 @@ async function down$25(db) {
347
347
  //#endregion
348
348
  //#region src/database/migrations/012_search.ts
349
349
  var _012_search_exports = /* @__PURE__ */ __exportAll({
350
- down: () => down$24,
351
- up: () => up$24
350
+ down: () => down$25,
351
+ up: () => up$25
352
352
  });
353
353
  /**
354
354
  * Migration: Search Support
@@ -356,11 +356,11 @@ var _012_search_exports = /* @__PURE__ */ __exportAll({
356
356
  * Adds search configuration to collections and searchable flag to fields.
357
357
  * FTS5 tables are created dynamically when search is enabled for a collection.
358
358
  */
359
- async function up$24(db) {
359
+ async function up$25(db) {
360
360
  await db.schema.alterTable("_emdash_collections").addColumn("search_config", "text").execute();
361
361
  await db.schema.alterTable("_emdash_fields").addColumn("searchable", "integer", (col) => col.defaultTo(0)).execute();
362
362
  }
363
- async function down$24(db) {
363
+ async function down$25(db) {
364
364
  await db.schema.alterTable("_emdash_fields").dropColumn("searchable").execute();
365
365
  await db.schema.alterTable("_emdash_collections").dropColumn("search_config").execute();
366
366
  }
@@ -368,8 +368,8 @@ async function down$24(db) {
368
368
  //#endregion
369
369
  //#region src/database/migrations/013_scheduled_publishing.ts
370
370
  var _013_scheduled_publishing_exports = /* @__PURE__ */ __exportAll({
371
- down: () => down$23,
372
- up: () => up$23
371
+ down: () => down$24,
372
+ up: () => up$24
373
373
  });
374
374
  /**
375
375
  * Migration: Add scheduled publishing support
@@ -378,7 +378,7 @@ var _013_scheduled_publishing_exports = /* @__PURE__ */ __exportAll({
378
378
  * When scheduled_at is set and status is 'scheduled', the content
379
379
  * will be auto-published when the scheduled time is reached.
380
380
  */
381
- async function up$23(db) {
381
+ async function up$24(db) {
382
382
  const tableNames = await listTablesLike(db, "ec_%");
383
383
  for (const tableName of tableNames) {
384
384
  const table = { name: tableName };
@@ -393,7 +393,7 @@ async function up$23(db) {
393
393
  `.execute(db);
394
394
  }
395
395
  }
396
- async function down$23(db) {
396
+ async function down$24(db) {
397
397
  const tableNames = await listTablesLike(db, "ec_%");
398
398
  for (const tableName of tableNames) {
399
399
  const table = { name: tableName };
@@ -410,10 +410,10 @@ async function down$23(db) {
410
410
  //#endregion
411
411
  //#region src/database/migrations/014_draft_revisions.ts
412
412
  var _014_draft_revisions_exports = /* @__PURE__ */ __exportAll({
413
- down: () => down$22,
414
- up: () => up$22
413
+ down: () => down$23,
414
+ up: () => up$23
415
415
  });
416
- async function up$22(db) {
416
+ async function up$23(db) {
417
417
  const tables = await db.selectFrom("_emdash_collections").select("slug").execute();
418
418
  for (const row of tables) {
419
419
  const tableName = `ec_${row.slug}`;
@@ -435,7 +435,7 @@ async function up$22(db) {
435
435
  `.execute(db);
436
436
  }
437
437
  }
438
- async function down$22(db) {
438
+ async function down$23(db) {
439
439
  const tables = await db.selectFrom("_emdash_collections").select("slug").execute();
440
440
  for (const row of tables) {
441
441
  const tableName = `ec_${row.slug}`;
@@ -459,8 +459,8 @@ async function down$22(db) {
459
459
  //#endregion
460
460
  //#region src/database/migrations/015_indexes.ts
461
461
  var _015_indexes_exports = /* @__PURE__ */ __exportAll({
462
- down: () => down$21,
463
- up: () => up$21
462
+ down: () => down$22,
463
+ up: () => up$22
464
464
  });
465
465
  /**
466
466
  * Add performance indexes for common query patterns.
@@ -473,7 +473,7 @@ var _015_indexes_exports = /* @__PURE__ */ __exportAll({
473
473
  * 5. Retroactive author_id + updated_at on existing ec_* content tables
474
474
  * (new tables get these from createContentTable() in registry.ts)
475
475
  */
476
- async function up$21(db) {
476
+ async function up$22(db) {
477
477
  await db.schema.createIndex("idx_media_mime_type").on("media").column("mime_type").execute();
478
478
  await db.schema.createIndex("idx_media_filename").on("media").column("filename").execute();
479
479
  await db.schema.createIndex("idx_media_created_at").on("media").column("created_at").execute();
@@ -493,7 +493,7 @@ async function up$21(db) {
493
493
  `.execute(db);
494
494
  }
495
495
  }
496
- async function down$21(db) {
496
+ async function down$22(db) {
497
497
  const tableNames = await listTablesLike(db, "ec_%");
498
498
  for (const tableName of tableNames) {
499
499
  const table = { name: tableName };
@@ -511,8 +511,8 @@ async function down$21(db) {
511
511
  //#endregion
512
512
  //#region src/database/migrations/016_api_tokens.ts
513
513
  var _016_api_tokens_exports = /* @__PURE__ */ __exportAll({
514
- down: () => down$20,
515
- up: () => up$20
514
+ down: () => down$21,
515
+ up: () => up$21
516
516
  });
517
517
  /**
518
518
  * API token tables for programmatic access.
@@ -521,27 +521,35 @@ var _016_api_tokens_exports = /* @__PURE__ */ __exportAll({
521
521
  * 1. _emdash_api_tokens — Personal Access Tokens (ec_pat_...)
522
522
  * 2. _emdash_oauth_tokens — OAuth access/refresh tokens (ec_oat_/ec_ort_...)
523
523
  * 3. _emdash_device_codes — OAuth Device Flow state (RFC 8628)
524
+ *
525
+ * Every CREATE is guarded with `.ifNotExists()` so the migration is safe to
526
+ * re-run against a partially-applied schema. See #954 for the failure mode:
527
+ * if `up()` crashes mid-way (D1 subrequest limit, isolate cancellation,
528
+ * transient connection error), the migration record never gets inserted
529
+ * into `_emdash_migrations`, and the next request retries `up()` from the
530
+ * top. Without these guards, the retry crashed with `table ... already
531
+ * exists` and blocked every subsequent boot of the Worker.
524
532
  */
525
- async function up$20(db) {
526
- await db.schema.createTable("_emdash_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();
527
- await db.schema.createIndex("idx_api_tokens_token_hash").on("_emdash_api_tokens").column("token_hash").execute();
528
- await db.schema.createIndex("idx_api_tokens_user_id").on("_emdash_api_tokens").column("user_id").execute();
529
- await db.schema.createTable("_emdash_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();
530
- await db.schema.createIndex("idx_oauth_tokens_user_id").on("_emdash_oauth_tokens").column("user_id").execute();
531
- await db.schema.createIndex("idx_oauth_tokens_expires").on("_emdash_oauth_tokens").column("expires_at").execute();
532
- await db.schema.createTable("_emdash_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();
533
+ async function up$21(db) {
534
+ await db.schema.createTable("_emdash_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();
535
+ await db.schema.createIndex("idx_api_tokens_token_hash").ifNotExists().on("_emdash_api_tokens").column("token_hash").execute();
536
+ await db.schema.createIndex("idx_api_tokens_user_id").ifNotExists().on("_emdash_api_tokens").column("user_id").execute();
537
+ await db.schema.createTable("_emdash_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();
538
+ await db.schema.createIndex("idx_oauth_tokens_user_id").ifNotExists().on("_emdash_oauth_tokens").column("user_id").execute();
539
+ await db.schema.createIndex("idx_oauth_tokens_expires").ifNotExists().on("_emdash_oauth_tokens").column("expires_at").execute();
540
+ await db.schema.createTable("_emdash_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();
533
541
  }
534
- async function down$20(db) {
535
- await db.schema.dropTable("_emdash_device_codes").execute();
536
- await db.schema.dropTable("_emdash_oauth_tokens").execute();
537
- await db.schema.dropTable("_emdash_api_tokens").execute();
542
+ async function down$21(db) {
543
+ await db.schema.dropTable("_emdash_device_codes").ifExists().execute();
544
+ await db.schema.dropTable("_emdash_oauth_tokens").ifExists().execute();
545
+ await db.schema.dropTable("_emdash_api_tokens").ifExists().execute();
538
546
  }
539
547
 
540
548
  //#endregion
541
549
  //#region src/database/migrations/017_authorization_codes.ts
542
550
  var _017_authorization_codes_exports = /* @__PURE__ */ __exportAll({
543
- down: () => down$19,
544
- up: () => up$19
551
+ down: () => down$20,
552
+ up: () => up$20
545
553
  });
546
554
  /**
547
555
  * Authorization codes for OAuth 2.1 Authorization Code + PKCE flow.
@@ -551,20 +559,20 @@ var _017_authorization_codes_exports = /* @__PURE__ */ __exportAll({
551
559
  *
552
560
  * Also adds client_id tracking to oauth_tokens for per-client revocation.
553
561
  */
554
- async function up$19(db) {
562
+ async function up$20(db) {
555
563
  await db.schema.createTable("_emdash_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();
556
564
  await db.schema.createIndex("idx_auth_codes_expires").on("_emdash_authorization_codes").column("expires_at").execute();
557
565
  await sql`ALTER TABLE _emdash_oauth_tokens ADD COLUMN client_id TEXT`.execute(db);
558
566
  }
559
- async function down$19(db) {
567
+ async function down$20(db) {
560
568
  await db.schema.dropTable("_emdash_authorization_codes").execute();
561
569
  }
562
570
 
563
571
  //#endregion
564
572
  //#region src/database/migrations/018_seo.ts
565
573
  var _018_seo_exports = /* @__PURE__ */ __exportAll({
566
- down: () => down$18,
567
- up: () => up$18
574
+ down: () => down$19,
575
+ up: () => up$19
568
576
  });
569
577
  /**
570
578
  * Migration: SEO support
@@ -577,7 +585,7 @@ var _018_seo_exports = /* @__PURE__ */ __exportAll({
577
585
  * need it. The `has_seo` flag controls whether the admin shows SEO fields
578
586
  * and whether the collection's content appears in sitemaps.
579
587
  */
580
- async function up$18(db) {
588
+ async function up$19(db) {
581
589
  await db.schema.createTable("_emdash_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("_emdash_seo_pk", ["collection", "content_id"]).execute();
582
590
  await sql`
583
591
  CREATE INDEX idx_emdash_seo_collection
@@ -588,7 +596,7 @@ async function up$18(db) {
588
596
  ADD COLUMN has_seo INTEGER NOT NULL DEFAULT 0
589
597
  `.execute(db);
590
598
  }
591
- async function down$18(db) {
599
+ async function down$19(db) {
592
600
  await sql`DROP TABLE IF EXISTS _emdash_seo`.execute(db);
593
601
  await sql`
594
602
  ALTER TABLE _emdash_collections
@@ -599,8 +607,8 @@ async function down$18(db) {
599
607
  //#endregion
600
608
  //#region src/database/migrations/019_i18n.ts
601
609
  var _019_i18n_exports = /* @__PURE__ */ __exportAll({
602
- down: () => down$17,
603
- up: () => up$17
610
+ down: () => down$18,
611
+ up: () => up$18
604
612
  });
605
613
  /**
606
614
  * Quote an identifier for use in raw SQL. Escapes embedded double-quotes
@@ -713,7 +721,7 @@ async function upPostgres(db) {
713
721
  ADD COLUMN translatable INTEGER NOT NULL DEFAULT 1
714
722
  `.execute(db);
715
723
  }
716
- async function up$17(db) {
724
+ async function up$18(db) {
717
725
  if (!isSqlite(db)) return upPostgres(db);
718
726
  const orphanedTmps = await listTablesLike(db, "ec_%_i18n_tmp");
719
727
  for (const tmpName of orphanedTmps) {
@@ -830,7 +838,7 @@ async function downPostgres(db) {
830
838
  await sql`ALTER TABLE ${sql.ref(t)} DROP COLUMN translation_group`.execute(db);
831
839
  }
832
840
  }
833
- async function down$17(db) {
841
+ async function down$18(db) {
834
842
  if (!isSqlite(db)) return downPostgres(db);
835
843
  await sql`
836
844
  ALTER TABLE _emdash_fields
@@ -937,8 +945,8 @@ async function down$17(db) {
937
945
  //#endregion
938
946
  //#region src/database/migrations/020_collection_url_pattern.ts
939
947
  var _020_collection_url_pattern_exports = /* @__PURE__ */ __exportAll({
940
- down: () => down$16,
941
- up: () => up$16
948
+ down: () => down$17,
949
+ up: () => up$17
942
950
  });
943
951
  /**
944
952
  * Migration: URL pattern for collections
@@ -947,13 +955,13 @@ var _020_collection_url_pattern_exports = /* @__PURE__ */ __exportAll({
947
955
  * can declare its own URL structure (e.g. "/{slug}" for pages, "/blog/{slug}"
948
956
  * for posts). Used for menu URL resolution, sitemaps, and path-based lookups.
949
957
  */
950
- async function up$16(db) {
958
+ async function up$17(db) {
951
959
  await sql`
952
960
  ALTER TABLE _emdash_collections
953
961
  ADD COLUMN url_pattern TEXT
954
962
  `.execute(db);
955
963
  }
956
- async function down$16(db) {
964
+ async function down$17(db) {
957
965
  await sql`
958
966
  ALTER TABLE _emdash_collections
959
967
  DROP COLUMN url_pattern
@@ -963,8 +971,8 @@ async function down$16(db) {
963
971
  //#endregion
964
972
  //#region src/database/migrations/021_remove_section_categories.ts
965
973
  var _021_remove_section_categories_exports = /* @__PURE__ */ __exportAll({
966
- down: () => down$15,
967
- up: () => up$15
974
+ down: () => down$16,
975
+ up: () => up$16
968
976
  });
969
977
  /**
970
978
  * Migration: Remove section categories
@@ -973,12 +981,12 @@ var _021_remove_section_categories_exports = /* @__PURE__ */ __exportAll({
973
981
  * Rather than building the missing UI for a feature with very little need at this stage,
974
982
  * we're removing the feature entirely.
975
983
  */
976
- async function up$15(db) {
984
+ async function up$16(db) {
977
985
  await db.schema.dropIndex("idx_sections_category").ifExists().execute();
978
986
  await db.schema.alterTable("_emdash_sections").dropColumn("category_id").execute();
979
987
  await db.schema.dropTable("_emdash_section_categories").execute();
980
988
  }
981
- async function down$15(db) {
989
+ async function down$16(db) {
982
990
  await db.schema.createTable("_emdash_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();
983
991
  await db.schema.alterTable("_emdash_sections").addColumn("category_id", "text", (col) => col.references("_emdash_section_categories.id").onDelete("set null")).execute();
984
992
  await db.schema.createIndex("idx_sections_category").on("_emdash_sections").columns(["category_id"]).execute();
@@ -987,8 +995,8 @@ async function down$15(db) {
987
995
  //#endregion
988
996
  //#region src/database/migrations/022_marketplace_plugin_state.ts
989
997
  var _022_marketplace_plugin_state_exports = /* @__PURE__ */ __exportAll({
990
- down: () => down$14,
991
- up: () => up$14
998
+ down: () => down$15,
999
+ up: () => up$15
992
1000
  });
993
1001
  /**
994
1002
  * Migration: Add marketplace fields to _plugin_state
@@ -997,7 +1005,7 @@ var _022_marketplace_plugin_state_exports = /* @__PURE__ */ __exportAll({
997
1005
  * whether a plugin was installed from config or marketplace,
998
1006
  * and which marketplace version is installed.
999
1007
  */
1000
- async function up$14(db) {
1008
+ async function up$15(db) {
1001
1009
  await sql`
1002
1010
  ALTER TABLE _plugin_state
1003
1011
  ADD COLUMN source TEXT NOT NULL DEFAULT 'config'
@@ -1012,7 +1020,7 @@ async function up$14(db) {
1012
1020
  WHERE source = 'marketplace'
1013
1021
  `.execute(db);
1014
1022
  }
1015
- async function down$14(db) {
1023
+ async function down$15(db) {
1016
1024
  await sql`
1017
1025
  DROP INDEX IF EXISTS idx_plugin_state_source
1018
1026
  `.execute(db);
@@ -1029,8 +1037,8 @@ async function down$14(db) {
1029
1037
  //#endregion
1030
1038
  //#region src/database/migrations/023_plugin_metadata.ts
1031
1039
  var _023_plugin_metadata_exports = /* @__PURE__ */ __exportAll({
1032
- down: () => down$13,
1033
- up: () => up$13
1040
+ down: () => down$14,
1041
+ up: () => up$14
1034
1042
  });
1035
1043
  /**
1036
1044
  * Migration: Add display metadata to _plugin_state
@@ -1039,7 +1047,7 @@ var _023_plugin_metadata_exports = /* @__PURE__ */ __exportAll({
1039
1047
  * so the admin UI can show meaningful info without re-fetching
1040
1048
  * from the marketplace on every page load.
1041
1049
  */
1042
- async function up$13(db) {
1050
+ async function up$14(db) {
1043
1051
  await sql`
1044
1052
  ALTER TABLE _plugin_state
1045
1053
  ADD COLUMN display_name TEXT
@@ -1049,7 +1057,7 @@ async function up$13(db) {
1049
1057
  ADD COLUMN description TEXT
1050
1058
  `.execute(db);
1051
1059
  }
1052
- async function down$13(db) {
1060
+ async function down$14(db) {
1053
1061
  await sql`
1054
1062
  ALTER TABLE _plugin_state
1055
1063
  DROP COLUMN description
@@ -1063,8 +1071,8 @@ async function down$13(db) {
1063
1071
  //#endregion
1064
1072
  //#region src/database/migrations/024_media_placeholders.ts
1065
1073
  var _024_media_placeholders_exports = /* @__PURE__ */ __exportAll({
1066
- down: () => down$12,
1067
- up: () => up$12
1074
+ down: () => down$13,
1075
+ up: () => up$13
1068
1076
  });
1069
1077
  /**
1070
1078
  * Migration: Add placeholder columns to media table
@@ -1072,7 +1080,7 @@ var _024_media_placeholders_exports = /* @__PURE__ */ __exportAll({
1072
1080
  * Stores blurhash and dominant_color for LQIP (Low Quality Image Placeholder)
1073
1081
  * support. Generated at upload time from image pixel data.
1074
1082
  */
1075
- async function up$12(db) {
1083
+ async function up$13(db) {
1076
1084
  await sql`
1077
1085
  ALTER TABLE media
1078
1086
  ADD COLUMN blurhash TEXT
@@ -1082,7 +1090,7 @@ async function up$12(db) {
1082
1090
  ADD COLUMN dominant_color TEXT
1083
1091
  `.execute(db);
1084
1092
  }
1085
- async function down$12(db) {
1093
+ async function down$13(db) {
1086
1094
  await sql`
1087
1095
  ALTER TABLE media
1088
1096
  DROP COLUMN dominant_color
@@ -1096,8 +1104,8 @@ async function down$12(db) {
1096
1104
  //#endregion
1097
1105
  //#region src/database/migrations/025_oauth_clients.ts
1098
1106
  var _025_oauth_clients_exports = /* @__PURE__ */ __exportAll({
1099
- down: () => down$11,
1100
- up: () => up$11
1107
+ down: () => down$12,
1108
+ up: () => up$12
1101
1109
  });
1102
1110
  /**
1103
1111
  * Migration: Create OAuth clients table
@@ -1108,18 +1116,18 @@ var _025_oauth_clients_exports = /* @__PURE__ */ __exportAll({
1108
1116
  * Each client has a set of pre-registered redirect URIs (JSON array).
1109
1117
  * The authorize endpoint rejects any redirect_uri not in the client's list.
1110
1118
  */
1111
- async function up$11(db) {
1119
+ async function up$12(db) {
1112
1120
  await db.schema.createTable("_emdash_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();
1113
1121
  }
1114
- async function down$11(db) {
1122
+ async function down$12(db) {
1115
1123
  await db.schema.dropTable("_emdash_oauth_clients").execute();
1116
1124
  }
1117
1125
 
1118
1126
  //#endregion
1119
1127
  //#region src/database/migrations/026_cron_tasks.ts
1120
1128
  var _026_cron_tasks_exports = /* @__PURE__ */ __exportAll({
1121
- down: () => down$10,
1122
- up: () => up$10
1129
+ down: () => down$11,
1130
+ up: () => up$11
1123
1131
  });
1124
1132
  /**
1125
1133
  * Migration: Create cron tasks table for plugin scheduled tasks.
@@ -1130,7 +1138,7 @@ var _026_cron_tasks_exports = /* @__PURE__ */ __exportAll({
1130
1138
  * The `next_run_at` + `status` + `enabled` index drives the "find overdue
1131
1139
  * tasks" query used by CronExecutor.tick().
1132
1140
  */
1133
- async function up$10(db) {
1141
+ async function up$11(db) {
1134
1142
  await db.schema.createTable("_emdash_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();
1135
1143
  await db.schema.createIndex("idx_cron_tasks_due").on("_emdash_cron_tasks").columns([
1136
1144
  "enabled",
@@ -1139,17 +1147,17 @@ async function up$10(db) {
1139
1147
  ]).execute();
1140
1148
  await db.schema.createIndex("idx_cron_tasks_plugin").on("_emdash_cron_tasks").column("plugin_id").execute();
1141
1149
  }
1142
- async function down$10(db) {
1150
+ async function down$11(db) {
1143
1151
  await db.schema.dropTable("_emdash_cron_tasks").execute();
1144
1152
  }
1145
1153
 
1146
1154
  //#endregion
1147
1155
  //#region src/database/migrations/027_comments.ts
1148
1156
  var _027_comments_exports = /* @__PURE__ */ __exportAll({
1149
- down: () => down$9,
1150
- up: () => up$9
1157
+ down: () => down$10,
1158
+ up: () => up$10
1151
1159
  });
1152
- async function up$9(db) {
1160
+ async function up$10(db) {
1153
1161
  await db.schema.createTable("_emdash_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("_emdash_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();
1154
1162
  await db.schema.createIndex("idx_comments_content").on("_emdash_comments").columns([
1155
1163
  "collection",
@@ -1165,30 +1173,30 @@ async function up$9(db) {
1165
1173
  await db.schema.alterTable("_emdash_collections").addColumn("comments_closed_after_days", "integer", (col) => col.defaultTo(90)).execute();
1166
1174
  await db.schema.alterTable("_emdash_collections").addColumn("comments_auto_approve_users", "integer", (col) => col.defaultTo(1)).execute();
1167
1175
  }
1168
- async function down$9(db) {
1176
+ async function down$10(db) {
1169
1177
  await db.schema.dropTable("_emdash_comments").execute();
1170
1178
  }
1171
1179
 
1172
1180
  //#endregion
1173
1181
  //#region src/database/migrations/028_drop_author_url.ts
1174
1182
  var _028_drop_author_url_exports = /* @__PURE__ */ __exportAll({
1175
- down: () => down$8,
1176
- up: () => up$8
1183
+ down: () => down$9,
1184
+ up: () => up$9
1177
1185
  });
1178
- async function up$8(db) {
1186
+ async function up$9(db) {
1179
1187
  await sql`ALTER TABLE _emdash_comments DROP COLUMN author_url`.execute(db);
1180
1188
  }
1181
- async function down$8(db) {
1189
+ async function down$9(db) {
1182
1190
  await db.schema.alterTable("_emdash_comments").addColumn("author_url", "text").execute();
1183
1191
  }
1184
1192
 
1185
1193
  //#endregion
1186
1194
  //#region src/database/migrations/029_redirects.ts
1187
1195
  var _029_redirects_exports = /* @__PURE__ */ __exportAll({
1188
- down: () => down$7,
1189
- up: () => up$7
1196
+ down: () => down$8,
1197
+ up: () => up$8
1190
1198
  });
1191
- async function up$7(db) {
1199
+ async function up$8(db) {
1192
1200
  await db.schema.createTable("_emdash_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();
1193
1201
  await db.schema.createIndex("idx_redirects_source").on("_emdash_redirects").column("source").execute();
1194
1202
  await db.schema.createIndex("idx_redirects_enabled").on("_emdash_redirects").column("enabled").execute();
@@ -1197,7 +1205,7 @@ async function up$7(db) {
1197
1205
  await db.schema.createIndex("idx_404_log_path").on("_emdash_404_log").column("path").execute();
1198
1206
  await db.schema.createIndex("idx_404_log_created").on("_emdash_404_log").column("created_at").execute();
1199
1207
  }
1200
- async function down$7(db) {
1208
+ async function down$8(db) {
1201
1209
  await db.schema.dropTable("_emdash_404_log").execute();
1202
1210
  await db.schema.dropTable("_emdash_redirects").execute();
1203
1211
  }
@@ -1205,8 +1213,8 @@ async function down$7(db) {
1205
1213
  //#endregion
1206
1214
  //#region src/database/migrations/030_widen_scheduled_index.ts
1207
1215
  var _030_widen_scheduled_index_exports = /* @__PURE__ */ __exportAll({
1208
- down: () => down$6,
1209
- up: () => up$6
1216
+ down: () => down$7,
1217
+ up: () => up$7
1210
1218
  });
1211
1219
  /**
1212
1220
  * Migration: Widen scheduled publishing index
@@ -1215,7 +1223,7 @@ var _030_widen_scheduled_index_exports = /* @__PURE__ */ __exportAll({
1215
1223
  * Published posts can now have scheduled draft changes, so widen the
1216
1224
  * index to cover all rows where scheduled_at IS NOT NULL.
1217
1225
  */
1218
- async function up$6(db) {
1226
+ async function up$7(db) {
1219
1227
  const tableNames = await listTablesLike(db, "ec_%");
1220
1228
  for (const tableName of tableNames) {
1221
1229
  const table = { name: tableName };
@@ -1229,7 +1237,7 @@ async function up$6(db) {
1229
1237
  `.execute(db);
1230
1238
  }
1231
1239
  }
1232
- async function down$6(db) {
1240
+ async function down$7(db) {
1233
1241
  const tableNames = await listTablesLike(db, "ec_%");
1234
1242
  for (const tableName of tableNames) {
1235
1243
  const table = { name: tableName };
@@ -1247,10 +1255,10 @@ async function down$6(db) {
1247
1255
  //#endregion
1248
1256
  //#region src/database/migrations/031_bylines.ts
1249
1257
  var _031_bylines_exports = /* @__PURE__ */ __exportAll({
1250
- down: () => down$5,
1251
- up: () => up$5
1258
+ down: () => down$6,
1259
+ up: () => up$6
1252
1260
  });
1253
- async function up$5(db) {
1261
+ async function up$6(db) {
1254
1262
  await db.schema.createTable("_emdash_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();
1255
1263
  await sql`
1256
1264
  CREATE UNIQUE INDEX ${sql.ref("idx_bylines_user_id_unique")}
@@ -1282,7 +1290,7 @@ async function up$5(db) {
1282
1290
  `.execute(db);
1283
1291
  }
1284
1292
  }
1285
- async function down$5(db) {
1293
+ async function down$6(db) {
1286
1294
  const tableNames = await listTablesLike(db, "ec_%");
1287
1295
  for (const tableName of tableNames) {
1288
1296
  await sql`
@@ -1300,8 +1308,8 @@ async function down$5(db) {
1300
1308
  //#endregion
1301
1309
  //#region src/database/migrations/032_rate_limits.ts
1302
1310
  var _032_rate_limits_exports = /* @__PURE__ */ __exportAll({
1303
- down: () => down$4,
1304
- up: () => up$4
1311
+ down: () => down$5,
1312
+ up: () => up$5
1305
1313
  });
1306
1314
  /**
1307
1315
  * Migration: Rate limits table + device code polling tracking.
@@ -1312,12 +1320,12 @@ var _032_rate_limits_exports = /* @__PURE__ */ __exportAll({
1312
1320
  * 2. Add last_polled_at column to _emdash_device_codes for
1313
1321
  * RFC 8628 slow_down enforcement.
1314
1322
  */
1315
- async function up$4(db) {
1323
+ async function up$5(db) {
1316
1324
  await db.schema.createTable("_emdash_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();
1317
1325
  await db.schema.createIndex("idx_rate_limits_window").on("_emdash_rate_limits").column("window").execute();
1318
1326
  await db.schema.alterTable("_emdash_device_codes").addColumn("last_polled_at", "text").execute();
1319
1327
  }
1320
- async function down$4(db) {
1328
+ async function down$5(db) {
1321
1329
  await db.schema.dropTable("_emdash_rate_limits").execute();
1322
1330
  await db.schema.alterTable("_emdash_device_codes").dropColumn("last_polled_at").execute();
1323
1331
  }
@@ -1325,8 +1333,8 @@ async function down$4(db) {
1325
1333
  //#endregion
1326
1334
  //#region src/database/migrations/033_optimize_content_indexes.ts
1327
1335
  var _033_optimize_content_indexes_exports = /* @__PURE__ */ __exportAll({
1328
- down: () => down$3,
1329
- up: () => up$3
1336
+ down: () => down$4,
1337
+ up: () => up$4
1330
1338
  });
1331
1339
  /**
1332
1340
  * Migration: Optimize content table indexes for D1 performance
@@ -1339,7 +1347,7 @@ var _033_optimize_content_indexes_exports = /* @__PURE__ */ __exportAll({
1339
1347
  *
1340
1348
  * Impact: Reduces D1 row reads by 90%+ for admin panel operations.
1341
1349
  */
1342
- async function up$3(db) {
1350
+ async function up$4(db) {
1343
1351
  const tableNames = await listTablesLike(db, "ec_%");
1344
1352
  for (const tableName of tableNames) {
1345
1353
  const table = { name: tableName };
@@ -1381,7 +1389,7 @@ async function up$3(db) {
1381
1389
  WHERE status = 'trash'
1382
1390
  `.execute(db);
1383
1391
  }
1384
- async function down$3(db) {
1392
+ async function down$4(db) {
1385
1393
  const tableNames = await listTablesLike(db, "ec_%");
1386
1394
  for (const tableName of tableNames) {
1387
1395
  const table = { name: tableName };
@@ -1414,10 +1422,10 @@ async function down$3(db) {
1414
1422
  //#endregion
1415
1423
  //#region src/database/migrations/034_published_at_index.ts
1416
1424
  var _034_published_at_index_exports = /* @__PURE__ */ __exportAll({
1417
- down: () => down$2,
1418
- up: () => up$2
1425
+ down: () => down$3,
1426
+ up: () => up$3
1419
1427
  });
1420
- async function up$2(db) {
1428
+ async function up$3(db) {
1421
1429
  const tableNames = await listTablesLike(db, "ec_%");
1422
1430
  for (const tableName of tableNames) {
1423
1431
  const table = { name: tableName };
@@ -1427,7 +1435,7 @@ async function up$2(db) {
1427
1435
  `.execute(db);
1428
1436
  }
1429
1437
  }
1430
- async function down$2(db) {
1438
+ async function down$3(db) {
1431
1439
  const tableNames = await listTablesLike(db, "ec_%");
1432
1440
  for (const tableName of tableNames) {
1433
1441
  const table = { name: tableName };
@@ -1438,8 +1446,8 @@ async function down$2(db) {
1438
1446
  //#endregion
1439
1447
  //#region src/database/migrations/035_bounded_404_log.ts
1440
1448
  var _035_bounded_404_log_exports = /* @__PURE__ */ __exportAll({
1441
- down: () => down$1,
1442
- up: () => up$1
1449
+ down: () => down$2,
1450
+ up: () => up$2
1443
1451
  });
1444
1452
  /**
1445
1453
  * Migration: Bounded 404 logging
@@ -1457,7 +1465,7 @@ var _035_bounded_404_log_exports = /* @__PURE__ */ __exportAll({
1457
1465
  * path and summing hits
1458
1466
  * - Adds a UNIQUE index on `path` so upsert semantics work
1459
1467
  */
1460
- async function up$1(db) {
1468
+ async function up$2(db) {
1461
1469
  const hitsExists = await columnExists(db, "_emdash_404_log", "hits");
1462
1470
  if (!hitsExists) await db.schema.alterTable("_emdash_404_log").addColumn("hits", "integer", (col) => col.notNull().defaultTo(1)).execute();
1463
1471
  if (!await columnExists(db, "_emdash_404_log", "last_seen_at")) await db.schema.alterTable("_emdash_404_log").addColumn("last_seen_at", "text").execute();
@@ -1506,7 +1514,7 @@ async function up$1(db) {
1506
1514
  await db.schema.dropIndex("idx_404_log_path").ifExists().execute();
1507
1515
  await db.schema.createIndex("idx_404_log_last_seen").ifNotExists().on("_emdash_404_log").column("last_seen_at").execute();
1508
1516
  }
1509
- async function down$1(db) {
1517
+ async function down$2(db) {
1510
1518
  await db.schema.dropIndex("idx_404_log_last_seen").ifExists().execute();
1511
1519
  await db.schema.dropIndex("idx_404_log_path_unique").ifExists().execute();
1512
1520
  await db.schema.createIndex("idx_404_log_path").ifNotExists().on("_emdash_404_log").column("path").execute();
@@ -1517,8 +1525,8 @@ async function down$1(db) {
1517
1525
  //#endregion
1518
1526
  //#region src/database/migrations/036_i18n_menus_and_taxonomies.ts
1519
1527
  var _036_i18n_menus_and_taxonomies_exports = /* @__PURE__ */ __exportAll({
1520
- down: () => down,
1521
- up: () => up
1528
+ down: () => down$1,
1529
+ up: () => up$1
1522
1530
  });
1523
1531
  /**
1524
1532
  * i18n for menus + taxonomies. Adds `locale` + `translation_group` to system
@@ -1529,7 +1537,7 @@ var _036_i18n_menus_and_taxonomies_exports = /* @__PURE__ */ __exportAll({
1529
1537
  function getDefaultLocale() {
1530
1538
  return getI18nConfig()?.defaultLocale ?? "en";
1531
1539
  }
1532
- async function up(db) {
1540
+ async function up$1(db) {
1533
1541
  const defaultLocale = getDefaultLocale();
1534
1542
  if (isSqlite(db)) {
1535
1543
  await sql.raw(`PRAGMA foreign_keys = OFF`).execute(db);
@@ -1718,7 +1726,7 @@ async function assertSingleLocale(db, defaultLocale) {
1718
1726
  if (count > 0) throw new Error(`Cannot revert migration 036_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/036_i18n_menus_and_taxonomies.ts.`);
1719
1727
  }
1720
1728
  }
1721
- async function down(db) {
1729
+ async function down$1(db) {
1722
1730
  const defaultLocale = getDefaultLocale();
1723
1731
  await assertSingleLocale(db, defaultLocale);
1724
1732
  const widenedTables = [
@@ -1807,6 +1815,19 @@ async function rebuildTaxonomyDefsDown(db) {
1807
1815
  await sql`ALTER TABLE _emdash_taxonomy_defs_old RENAME TO _emdash_taxonomy_defs`.execute(db);
1808
1816
  }
1809
1817
 
1818
+ //#endregion
1819
+ //#region src/database/migrations/037_credential_algorithm.ts
1820
+ var _037_credential_algorithm_exports = /* @__PURE__ */ __exportAll({
1821
+ down: () => down,
1822
+ up: () => up
1823
+ });
1824
+ async function up(db) {
1825
+ if (!await columnExists(db, "credentials", "algorithm")) await db.schema.alterTable("credentials").addColumn("algorithm", "integer", (col) => col.notNull().defaultTo(-7)).execute();
1826
+ }
1827
+ async function down(db) {
1828
+ if (await columnExists(db, "credentials", "algorithm")) await db.schema.alterTable("credentials").dropColumn("algorithm").execute();
1829
+ }
1830
+
1810
1831
  //#endregion
1811
1832
  //#region src/database/migrations/runner.ts
1812
1833
  const MIGRATIONS = Object.freeze({
@@ -1844,7 +1865,8 @@ const MIGRATIONS = Object.freeze({
1844
1865
  "033_optimize_content_indexes": _033_optimize_content_indexes_exports,
1845
1866
  "034_published_at_index": _034_published_at_index_exports,
1846
1867
  "035_bounded_404_log": _035_bounded_404_log_exports,
1847
- "036_i18n_menus_and_taxonomies": _036_i18n_menus_and_taxonomies_exports
1868
+ "036_i18n_menus_and_taxonomies": _036_i18n_menus_and_taxonomies_exports,
1869
+ "037_credential_algorithm": _037_credential_algorithm_exports
1848
1870
  });
1849
1871
  /** Total number of registered migrations. Exported for use in tests. */
1850
1872
  const MIGRATION_COUNT = Object.keys(MIGRATIONS).length;
@@ -2041,4 +2063,4 @@ async function rollbackMigration(db) {
2041
2063
 
2042
2064
  //#endregion
2043
2065
  export { __exportAll as i, rollbackMigration as n, runMigrations as r, getMigrationStatus as t };
2044
- //# sourceMappingURL=runner-DMnlIkh4.mjs.map
2066
+ //# sourceMappingURL=runner-DIcU2UCC.mjs.map