Spaces:
Sleeping
Sleeping
Download backend/scripts/runMigrations.mjs from bardd/mike-backend: direct link, hf CLI and curl.
- Browser
- Download file 927 Bytes
-
https://huggingface.co/spaces/bardd/mike-backend/resolve/main/backend/scripts/runMigrations.mjs
- Command line
-
hf download hf://spaces/bardd/mike-backend/backend/scripts/runMigrations.mjs
-
curl -L -o runMigrations.mjs https://huggingface.co/spaces/bardd/mike-backend/resolve/main/backend/scripts/runMigrations.mjs
927 Bytes
| import pg from "pg"; | |
| import { runMigrations } from "./migrationLib.mjs"; | |
| const databaseUrl = process.env.DATABASE_URL; | |
| if (!databaseUrl) { | |
| console.error("DATABASE_URL is required"); | |
| process.exit(1); | |
| } | |
| const pool = new pg.Pool({ connectionString: databaseUrl }); | |
| const migrationsDir = process.env.MIKE_MIGRATIONS_DIR; | |
| const allowMockAuthBootstrap = | |
| process.env.MIKE_ALLOW_MOCK_AUTH_BOOTSTRAP === "1"; | |
| try { | |
| const result = await runMigrations( | |
| pool, | |
| { | |
| ...(migrationsDir ? { migrationsDir } : {}), | |
| allowMockAuthBootstrap, | |
| }, | |
| ); | |
| if (result.applied.length === 0) { | |
| console.log("No pending migrations"); | |
| } else { | |
| console.log(`Applied migrations: ${result.applied.join(", ")}`); | |
| } | |
| } catch (error) { | |
| console.error(error instanceof Error ? error.message : error); | |
| process.exitCode = 1; | |
| } finally { | |
| await pool.end(); | |
| } | |
| if (process.exitCode) { | |
| process.exit(process.exitCode); | |
| } | |