@filo-cms/db
v0.3.2
Published
Filo CMS database layer: Drizzle schema, migrations, seed and migration runner.
Downloads
39
Readme
@filo-cms/db
Database layer for Filo CMS: Drizzle ORM schemas for PostgreSQL and SQLite/libSQL (engine inferred from DATABASE_URL), bundled per-dialect SQL migrations, and programmatic migration/seed runners.
This package is primarily an internal dependency of
@filo-cms/cms— you rarely install it directly. It is published so CMS projects, plugins and tooling can share one schema and one migration path.
Install
npm install @filo-cms/dbUsage
import { createDb, useDb, schema } from "@filo-cms/db";
const db = createDb(process.env.DATABASE_URL!);
const posts = await db.select().from(schema.contentEntries);Migrations
SQL migrations ship inside the package and can be applied programmatically:
import { runMigrations } from "@filo-cms/db/migrate";
await runMigrations(process.env.DATABASE_URL!, {
retries: 15, // wait for the database to come up (containers)
retryDelayMs: 2000,
});Seeding
import { seedCore, ensureAdminUser } from "@filo-cms/db/seed";
await seedCore(db); // idempotent: permissions, system roles, defaults
await ensureAdminUser(db, "[email protected]", "secret"); // create/promote an admin (never overwrites passwords)Both are idempotent and safe to run on every boot — this is exactly what the CMS bootstrap plugin does.
Exports
| Subpath | Contents |
|---|---|
| . | createDb, useDb, schema, password & API-key utilities |
| ./schema | raw Drizzle table definitions |
| ./migrate | runMigrations() |
| ./seed | seedCore(), ensureAdminUser() |
Links
- Filo CMS repository & documentation
- License: MIT
