@momentumcms/core 0.5.4 → 0.5.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momentumcms/core",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "Core collection config, fields, hooks, and access control for Momentum CMS",
5
5
  "license": "MIT",
6
6
  "author": "Momentum CMS Contributors",
package/src/index.cjs CHANGED
@@ -71,6 +71,7 @@ __export(src_exports, {
71
71
  richText: () => richText,
72
72
  row: () => row,
73
73
  select: () => select,
74
+ shouldSyncSchema: () => shouldSyncSchema,
74
75
  slug: () => slug,
75
76
  tabs: () => tabs,
76
77
  text: () => text,
@@ -676,6 +677,15 @@ function defineMomentumConfig(config) {
676
677
  migrations: resolveMigrationConfig(config.migrations)
677
678
  };
678
679
  }
680
+ function shouldSyncSchema(config) {
681
+ const explicit = config.db.syncSchema ?? "auto";
682
+ if (typeof explicit === "boolean")
683
+ return explicit;
684
+ if (!config.migrations)
685
+ return true;
686
+ const mode = resolveMigrationMode(config.migrations.mode);
687
+ return mode !== "migrate";
688
+ }
679
689
  function getDbAdapter(config) {
680
690
  return config.db.adapter;
681
691
  }
@@ -832,6 +842,7 @@ function hasVersionDrafts(collection) {
832
842
  richText,
833
843
  row,
834
844
  select,
845
+ shouldSyncSchema,
835
846
  slug,
836
847
  tabs,
837
848
  text,
package/src/index.js CHANGED
@@ -594,6 +594,15 @@ function defineMomentumConfig(config) {
594
594
  migrations: resolveMigrationConfig(config.migrations)
595
595
  };
596
596
  }
597
+ function shouldSyncSchema(config) {
598
+ const explicit = config.db.syncSchema ?? "auto";
599
+ if (typeof explicit === "boolean")
600
+ return explicit;
601
+ if (!config.migrations)
602
+ return true;
603
+ const mode = resolveMigrationMode(config.migrations.mode);
604
+ return mode !== "migrate";
605
+ }
597
606
  function getDbAdapter(config) {
598
607
  return config.db.adapter;
599
608
  }
@@ -749,6 +758,7 @@ export {
749
758
  richText,
750
759
  row,
751
760
  select,
761
+ shouldSyncSchema,
752
762
  slug,
753
763
  tabs,
754
764
  text,
@@ -193,6 +193,17 @@ export interface DatabaseConfig {
193
193
  * Use @momentumcms/db-drizzle for Drizzle ORM support.
194
194
  */
195
195
  adapter: DatabaseAdapter;
196
+ /**
197
+ * Whether to auto-sync the database schema on server start.
198
+ *
199
+ * - `true`: Always run `adapter.initialize()` (CREATE TABLE IF NOT EXISTS).
200
+ * - `false`: Never auto-sync — expect migrations to be run separately.
201
+ * - `'auto'`: Sync when no migration config or in `push` mode;
202
+ * skip when migration mode is `migrate`.
203
+ *
204
+ * @default 'auto'
205
+ */
206
+ syncSchema?: boolean | 'auto';
196
207
  }
197
208
  /**
198
209
  * Admin component overrides and layout slot registrations.
@@ -459,6 +470,14 @@ export interface ResolvedMomentumConfig extends MomentumConfig {
459
470
  * ```
460
471
  */
461
472
  export declare function defineMomentumConfig(config: MomentumConfig): ResolvedMomentumConfig;
473
+ /**
474
+ * Determine whether the server should auto-sync the database schema on boot.
475
+ *
476
+ * Resolution order:
477
+ * 1. Explicit `db.syncSchema` (true / false) — always wins.
478
+ * 2. `'auto'` (or omitted) — sync unless migration mode is `'migrate'`.
479
+ */
480
+ export declare function shouldSyncSchema(config: MomentumConfig | ResolvedMomentumConfig): boolean;
462
481
  /**
463
482
  * Gets the database adapter from the config.
464
483
  */