Files

10 lines
833 B
JavaScript

import { spawnSync } from 'node:child_process';
import { compose } from './compose.mjs';
// The fixed, separate database is never dropped. No credentials are passed on the command line.
compose(['exec', '-T', 'db', 'sh', '-c', `export MYSQL_PWD="$MARIADB_ROOT_PASSWORD"; mariadb -u root -e "CREATE DATABASE IF NOT EXISTS model_delivery_test CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; GRANT ALL PRIVILEGES ON model_delivery_test.* TO '$MARIADB_USER'@'%';"`]);
for (const script of ['db:migrate', 'db:seed']) {
// pnpm exposes its JS entry point to scripts; invoking Node avoids Windows shell quoting.
const result = spawnSync(process.execPath, [process.env.npm_execpath, script], { stdio: 'inherit', env: { ...process.env, DB_NAME: 'model_delivery_test' } });
if (result.status !== 0) process.exit(result.status ?? 1);
}