Database Migrations
This directory contains database migration files for Katasumi.
Migration File Format
Migration files should follow this naming convention:
YYYYMMDD_HHMMSS_description.js
Example: 20260126_221245_initial_schema.js
Migration Structure
Each migration file must export two functions:
exports.up = async function up(db) {
await db.$executeRawUnsafe(`CREATE TABLE ...`);
};
exports.down = async function down(db) {
await db.$executeRawUnsafe(`DROP TABLE ...`);
};
Running Migrations
From the monorepo root:
npm run migrate
npm run migrate:rollback
npm run migrate:status
From the core package:
cd packages/core
DATABASE_URL="file:./database.db" npm run migrate
DATABASE_URL="postgres://user:password@localhost:5432/db" DB_TYPE=postgres npm run migrate
Supported Databases
- SQLite (default)
- PostgreSQL
Both databases use the same migration files, which are written to be compatible with both systems.