Files
civitai__civitai/scripts/prisma-mark-migration-applied.mjs
T
Briant Diehl 343c3c9bb4 fix(build): update prisma/build paths for the db-schema package move
The Prisma schema/migrations moved to packages/civitai-db-schema; point the build and migration tooling at the new path.

- Dockerfile: workspace-aware deps layer (copy pnpm-workspace.yaml + packages/*), schema paths -> packages/civitai-db-schema/prisma
- prisma-migrate-with-views-workaround / mark-migration-applied / prepare-programmability / local-dev/run_migrations: updated hardcoded prisma/ paths

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 15:34:21 -06:00

19 lines
746 B
JavaScript

import { readdir } from 'fs/promises';
import { spawnSync } from 'child_process';
const spawnOptions = { stdio: 'inherit', shell: true };
// Get the last migration folder in the /migrations directory
const migrations = await readdir('packages/civitai-db-schema/prisma/migrations', { withFileTypes: true });
const lastMigration = migrations.filter((dirent) => dirent.isDirectory()).sort((a, b) => b.name.localeCompare(a.name))[0].name;
console.log(`Marking migration "${lastMigration}" as applied...`);
try {
const { error } = spawnSync(`prisma migrate resolve --applied "${lastMigration}"`, spawnOptions);
if (error) throw error;
} catch (error) {
// Restore the schema
console.log('Failed...');
// Rethrow the error
throw error;
}