mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
several changes
This commit is contained in:
parent
1ed9c6150f
commit
cd02113441
@ -34,7 +34,7 @@
|
||||
"watch-docs": "pnpm run with-env bash -c 'tsx watch --clear-screen=false scripts/generate-openapi-fumadocs.ts && pnpm run --filter=@stackframe/stack-docs generate-openapi-docs'",
|
||||
"generate-openapi-fumadocs": "pnpm run with-env tsx scripts/generate-openapi-fumadocs.ts",
|
||||
"generate-keys": "pnpm run with-env tsx scripts/generate-keys.ts",
|
||||
"db-seed-script": "pnpm run with-env tsx prisma/seed.ts",
|
||||
"db-seed-script": "pnpm run db:seed",
|
||||
"verify-data-integrity": "pnpm run with-env tsx scripts/verify-data-integrity.ts"
|
||||
},
|
||||
"prisma": {
|
||||
|
||||
@ -10,7 +10,7 @@ import { errorToNiceString, throwErr } from '@stackframe/stack-shared/dist/utils
|
||||
|
||||
const globalPrisma = new PrismaClient();
|
||||
|
||||
async function seed() {
|
||||
export async function seed() {
|
||||
console.log('Seeding database...');
|
||||
|
||||
// Optional default admin user
|
||||
@ -473,9 +473,11 @@ async function seed() {
|
||||
|
||||
process.env.STACK_SEED_MODE = 'true';
|
||||
|
||||
seed().catch(async (e) => {
|
||||
console.error(errorToNiceString(e));
|
||||
await globalPrisma.$disconnect();
|
||||
process.exit(1);
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
}).finally(async () => await globalPrisma.$disconnect());
|
||||
if (require.main === module) {
|
||||
seed().catch(async (e) => {
|
||||
console.error(errorToNiceString(e));
|
||||
await globalPrisma.$disconnect();
|
||||
process.exit(1);
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
}).finally(async () => await globalPrisma.$disconnect());
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import { globalPrismaClient, globalPrismaSchema, sqlQuoteIdent } from "@/prisma-
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { execSync } from "child_process";
|
||||
import * as readline from 'readline';
|
||||
import { seed } from "../prisma/seed";
|
||||
|
||||
const dropSchema = async () => {
|
||||
await globalPrismaClient.$executeRaw(Prisma.sql`DROP SCHEMA ${sqlQuoteIdent(globalPrismaSchema)} CASCADE`);
|
||||
@ -12,10 +13,6 @@ const dropSchema = async () => {
|
||||
await globalPrismaClient.$executeRaw(Prisma.sql`GRANT ALL ON SCHEMA ${sqlQuoteIdent(globalPrismaSchema)} TO public`);
|
||||
};
|
||||
|
||||
const seed = async () => {
|
||||
execSync('pnpm run db-seed-script', { stdio: 'inherit' });
|
||||
};
|
||||
|
||||
const promptDropDb = async () => {
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
|
||||
@ -75,7 +75,7 @@ RUN apt-get update && \
|
||||
COPY --from=builder --chown=node:node /app/apps/backend/.next/standalone ./
|
||||
COPY --from=builder --chown=node:node /app/apps/backend/.next/static ./apps/backend/.next/static
|
||||
COPY --from=builder --chown=node:node /app/apps/backend/prisma ./apps/backend/prisma
|
||||
COPY --from=builder --chown=node:node /app/apps/backend/dist/db-migrations.js ./apps/backend
|
||||
COPY --from=builder --chown=node:node /app/apps/backend/dist ./apps/backend
|
||||
|
||||
# Copy built dashboard
|
||||
COPY --from=builder --chown=node:node /app/apps/dashboard/.next/standalone ./
|
||||
|
||||
@ -38,7 +38,7 @@ if [ "$STACK_SKIP_MIGRATIONS" = "true" ]; then
|
||||
else
|
||||
echo "Running migrations..."
|
||||
cd apps/backend
|
||||
node db-migrations.js migrate
|
||||
node dist/db-migrations.js migrate
|
||||
cd ../..
|
||||
fi
|
||||
|
||||
@ -47,7 +47,7 @@ if [ "$STACK_SKIP_SEED_SCRIPT" = "true" ]; then
|
||||
else
|
||||
echo "Running seed script..."
|
||||
cd apps/backend
|
||||
node db-migrations.js seed
|
||||
node dist/db-migrations.js seed
|
||||
cd ../..
|
||||
fi
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user