Compare commits

...

5 Commits

Author SHA1 Message Date
81c43e01d3 fix: test 2024-03-07 12:38:02 +08:00
ffcb4fda20 fix: remove invalid seed 2024-03-07 12:12:24 +08:00
530508f421 fix: remove invalid seed 2024-03-07 12:09:14 +08:00
e748b1898e fix: add direct neon connection URL 2024-03-07 11:50:16 +08:00
88ffdb0066 fix: remove duplicate neon pooler 2024-03-06 16:36:48 +08:00
6 changed files with 39 additions and 24 deletions

View File

@ -15,6 +15,10 @@ export const getDatabaseUrl = () => {
process.env.NEXT_PRIVATE_DIRECT_DATABASE_URL = process.env.DATABASE_URL;
}
if (process.env.DATABASE_URL_UNPOOLED) {
process.env.NEXT_PRIVATE_DIRECT_DATABASE_URL = process.env.DATABASE_URL_UNPOOLED;
}
if (process.env.POSTGRES_PRISMA_URL) {
process.env.NEXT_PRIVATE_DATABASE_URL = process.env.POSTGRES_PRISMA_URL;
}
@ -40,18 +44,5 @@ export const getDatabaseUrl = () => {
process.env.NEXT_PRIVATE_DATABASE_URL = url.toString().replace('https://', 'postgres://');
}
// Support for neon.tech (Neon Database)
if (url.hostname.endsWith('neon.tech')) {
const [projectId, ...rest] = url.hostname.split('.');
if (!projectId.endsWith('-pooler')) {
url.hostname = `${projectId}-pooler.${rest.join('.')}`;
}
url.searchParams.set('pgbouncer', 'true');
process.env.NEXT_PRIVATE_DATABASE_URL = url.toString().replace('https://', 'postgres://');
}
return process.env.NEXT_PRIVATE_DATABASE_URL;
};

View File

@ -0,0 +1,11 @@
-- CreateTable
CREATE TABLE "DummyData" (
"id" TEXT NOT NULL,
"userId" INTEGER NOT NULL,
"hello" TEXT,
CONSTRAINT "DummyData_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "DummyData" ADD CONSTRAINT "DummyData_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -52,10 +52,19 @@ model User {
securityAuditLogs UserSecurityAuditLog[]
Webhooks Webhook[]
siteSettings SiteSettings[]
dummyData DummyData[]
@@index([email])
}
model DummyData {
id String @id @default(cuid())
userId Int
hello String?
User User? @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model UserProfile {
id Int @id
bio String?

View File

@ -13,7 +13,13 @@ const seedDatabase = async () => {
if ('seedDatabase' in mod && typeof mod.seedDatabase === 'function') {
console.log(`[SEEDING]: ${file}`);
await mod.seedDatabase();
try {
await mod.seedDatabase();
} catch (e) {
console.log(`[SEEDING]: Seed failed for ${file}`);
console.error(e);
}
}
}
}

View File

@ -6,7 +6,6 @@ set -eo pipefail
# Get the directory of this script, regardless of where it is called from.
SCRIPT_DIR="$(readlink -f "$(dirname "$0")")"
function log() {
echo "[VercelBuild]: $1"
}
@ -69,19 +68,17 @@ function remap_database_integration() {
export NEXT_PRIVATE_DIRECT_DATABASE_URL="$DATABASE_URL"
fi
if [[ ! -z "$DATABASE_URL_UNPOOLED" ]]; then
log "Remapping for Neon integration"
export NEXT_PRIVATE_DATABASE_URL="$DATABASE_URL&pgbouncer=true"
export NEXT_PRIVATE_DIRECT_DATABASE_URL="$DATABASE_URL_UNPOOLED"
fi
if [[ ! -z "$POSTGRES_URL_NON_POOLING" ]]; then
export NEXT_PRIVATE_DATABASE_URL="$POSTGRES_URL?pgbouncer=true"
export NEXT_PRIVATE_DIRECT_DATABASE_URL="$POSTGRES_URL_NON_POOLING"
fi
if [[ "$NEXT_PRIVATE_DATABASE_URL" == *"neon.tech"* ]]; then
log "Remapping for Neon integration"
PROJECT_ID="$(echo "$PGHOST" | cut -d'.' -f1)"
PGBOUNCER_HOST="$(echo "$PGHOST" | sed "s/${PROJECT_ID}/${PROJECT_ID}-pooler/")"
export NEXT_PRIVATE_DATABASE_URL="postgres://${PGUSER}:${PGPASSWORD}@${PGBOUNCER_HOST}/${PGDATABASE}?pgbouncer=true"
fi
}
# Navigate to the root of the project.

View File

@ -90,6 +90,7 @@
"FONT_CAVEAT_URI",
"POSTGRES_URL",
"DATABASE_URL",
"DATABASE_URL_UNPOOLED",
"POSTGRES_PRISMA_URL",
"POSTGRES_URL_NON_POOLING",
"E2E_TEST_AUTHENTICATE_USERNAME",