import type { Kysely } from "kysely"; import { sql } from "kysely"; import { columnExists } from "../dialect-helpers.js"; /** * Where a collection's entries live. * * _emdash_collections.storage 'db' (default) rows in the ec_* table * 'git' JSON files in the site's git repo * (content//.json); * the ec_* table stays for schema only * * Git-backed collections are read from and written to the repo directly — * saving in the admin is a commit — so seldom-changing, version-worthy * content (form definitions, site structure) lives with the site's code, * while frequently edited or sensitive data stays in the database. */ export async function up(db: Kysely): Promise { if (!(await columnExists(db, "_emdash_collections", "storage"))) { await sql`ALTER TABLE ${sql.ref("_emdash_collections")} ADD COLUMN ${sql.ref("storage")} text NOT NULL DEFAULT 'db'`.execute( db, ); } } export async function down(_db: Kysely): Promise { // Forward-only: SQLite can't drop columns portably and 'db' rows are unaffected. }