mirror of
https://github.com/civitai/civitai.git
synced 2026-09-20 22:08:18 +08:00
343c3c9bb4
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>
19 lines
746 B
JavaScript
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;
|
|
}
|