Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions app/db.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,9 @@ function getClient() {
throw new Error('DATABASE_URL secret not set');
}

const databaseUrl = new URL(DATABASE_URL);
logger.info(`🔌 setting up prisma client to ${new URL(DATABASE_URL).host}`);

logger.info(`🔌 setting up prisma client to ${databaseUrl.host}`);

const adapter = new PrismaMariaDb({
host: databaseUrl.hostname,
port: parseInt(databaseUrl.port || '3306'),
user: databaseUrl.username,
password: databaseUrl.password,
database: databaseUrl.pathname.slice(1), // Remove leading '/'
connectionLimit: 5,
});
const adapter = new PrismaMariaDb(DATABASE_URL);

// NOTE: during development if you change anything in this function, remember
// that this only runs once per server restart and won't automatically be
Expand All @@ -54,10 +45,7 @@ function getClient() {
const client = new PrismaClient({ adapter });

// connect eagerly
client
.$connect()
.then(() => console.debug('✅ Prisma connected successfully'))
.catch((err) => console.error('❌ Prisma connection failed:', err));
client.$connect();

return client;
}
Expand Down
13 changes: 1 addition & 12 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,11 @@ import { PrismaClient } from '@prisma/client-and-server';
import { PrismaMariaDb } from '@prisma/adapter-mariadb';

const DATABASE_URL = process.env.DATABASE_URL;

if (!DATABASE_URL) {
throw new Error('DATABASE_URL environment variable is not set');
}

// Parse connection details
const url = new URL(DATABASE_URL);
const adapter = new PrismaMariaDb({
host: url.hostname,
port: parseInt(url.port || '3306'),
user: url.username,
password: url.password,
database: url.pathname.slice(1),
connectionLimit: 5,
});

const adapter = new PrismaMariaDb(DATABASE_URL);
const prisma = new PrismaClient({ adapter });

async function seed() {
Expand Down