refactor: remove all SQLite code, standardize on PostgreSQL

- Remove database provider switching logic from prisma.ts and auth.ts
- Hardcode PostgreSQL as the only supported database
- Remove switch-database.js and use-dev-db.js scripts
- Remove Python utility scripts that used sqlite3 directly
- Update justfile to remove SQLite test targets
- Update package.json to remove db:switch script
- Update Dockerfile.ci-base to default to PostgreSQL
- Update .env.example to remove SQLite mention
- Update playwright.config.ts comments
- Update .gitignore to remove SQLite file patterns

This eliminates the root cause of test failures: the dev server and test
Prisma client were using different databases (PostgreSQL vs SQLite).
This commit is contained in:
2026-05-02 04:09:37 -07:00
parent 08152fba51
commit 28fecdfaad
14 changed files with 91 additions and 873 deletions
+16 -66
View File
@@ -22,8 +22,7 @@ IMAGE_TAG_COMMIT := `git rev-parse --short HEAD`
# --- Variables ---
# Database
DB_CONTAINER := "euchre-camp-postgres"
DATABASE_PROVIDER := env_var_or_default("DATABASE_PROVIDER", "sqlite")
DATABASE_URL := env_var_or_default("DATABASE_URL", "file:./prisma/dev.db")
DATABASE_URL := env_var_or_default("DATABASE_URL", "")
# --- Setup & Installation ---
@@ -32,7 +31,7 @@ setup:
@echo "Installing dependencies..."
npm install
@echo "Setting up database..."
npm run db:setup-postgres
npm run db:setup-dev
@echo "Generating Prisma client..."
npx prisma generate
@@ -56,56 +55,33 @@ format:
# --- Testing ---
# Run all tests (unit + acceptance with SQLite)
# Note: Uses Docker containers for consistent environment
test: test-unit test-acceptance-sqlite
# Run all tests (unit + acceptance)
test: test-unit test-acceptance
# Run all tests with PostgreSQL (Docker)
test-pg: test-unit test-acceptance-postgres
# Run unit tests (Vitest)
# Run unit tests
test-unit:
npm run test:run
# Run acceptance tests with SQLite (fast, no Docker needed)
test-acceptance-sqlite:
@echo "Running acceptance tests with SQLite..."
DATABASE_PROVIDER=sqlite DATABASE_URL=file:./prisma/ci.db BETTER_AUTH_SECRET=test-secret-key npm run test:acceptance
# Run acceptance tests with PostgreSQL (Docker)
test-acceptance-postgres:
@echo "Starting Docker containers for acceptance tests..."
docker compose up -d
@echo "Waiting for services to be ready..."
sleep 10
# Run acceptance tests (Playwright)
test-acceptance:
@echo "Running acceptance tests..."
npm run test:acceptance
@echo "Stopping Docker containers..."
docker compose down
# Run Cucumber e2e tests with SQLite
test-cucumber-sqlite:
# Run Cucumber e2e tests
test-cucumber:
@echo "Clearing Next.js cache..."
rm -rf .next/
@echo "Running Cucumber e2e tests with SQLite..."
DATABASE_PROVIDER=sqlite DATABASE_URL=file:./prisma/ci.db npm run test:acceptance:cucumber
# Run Cucumber e2e tests with PostgreSQL (uses .env.development)
test-cucumber-postgres:
@echo "Clearing Next.js cache..."
rm -rf .next/
@echo "Running Cucumber e2e tests with PostgreSQL..."
@echo "Running Cucumber e2e tests..."
npm run test:acceptance:cucumber
# Run Cucumber e2e tests with PostgreSQL against production build
# This is more reliable than dev server (no HMR, faster API responses)
test-cucumber-postgres-prod:
# Run Cucumber e2e tests against production build
test-cucumber-prod:
@echo "Clearing Next.js cache..."
rm -rf .next/
@echo "Building application for production..."
bun run build
@echo "Starting production server in background..."
DATABASE_URL=$(grep DATABASE_URL .env.development | cut -d'=' -f2 | tr -d '"') DATABASE_PROVIDER=postgresql bun run start > /tmp/next-prod.log 2>&1 &
bun run start > /tmp/next-prod.log 2>&1 &
SERVER_PID=$$!
@echo "Waiting for server to be ready..."
sleep 15
@@ -115,9 +91,6 @@ test-cucumber-postgres-prod:
kill $$SERVER_PID 2>/dev/null || true
@echo "Tests completed."
# Run all e2e tests (both Playwright and Cucumber)
test-e2e: test-acceptance-sqlite test-cucumber-sqlite
# Run database migrations (Prisma)
migrate:
npx prisma migrate dev
@@ -126,13 +99,6 @@ migrate:
seed:
npm run db:seed
# Switch database provider
db-switch-sqlite:
npm run db:switch sqlite
db-switch-postgres:
npm run db:switch postgresql
# --- Docker ---
# Build the Docker image (standard build)
@@ -148,7 +114,6 @@ docker-build-commit:
docker-build-full: docker-build docker-build-commit
# Fast rebuild using Docker BuildKit cache
# Uses build cache to speed up rebuilds when only code changes
docker-rebuild-fast:
@echo "Fast rebuilding Docker image {{PROJECT}}:{{IMAGE_TAG}}..."
DOCKER_BUILDKIT=1 docker build \
@@ -195,19 +160,14 @@ docker-push: docker-build-full
# --- CI/CD Pipeline Simulation ---
# Run full CI pipeline locally (lint, test, build, push)
# Matches the Gitea Actions workflow
ci: lint typecheck test-unit test-acceptance-sqlite docker-build
# Run full CI pipeline locally (lint, test, build)
ci: lint typecheck test-unit test-acceptance docker-build
@echo "CI Pipeline completed successfully!"
# PR validation (what runs on pull requests)
pr-validate: lint typecheck test-unit test-acceptance-sqlite
pr-validate: lint typecheck test-unit test-acceptance
@echo "PR validation completed successfully!"
# Run CI with PostgreSQL (for release workflow simulation)
ci-postgres: lint typecheck test-unit test-acceptance-postgres docker-build
@echo "CI Pipeline with PostgreSQL completed successfully!"
# --- Utilities ---
# Show help information
@@ -279,13 +239,3 @@ workflow-status:
@echo "PR Workflow: Runs unit + acceptance tests on pull requests"
@echo "Test Workflow: Runs unit tests on all branch pushes"
@echo "Release Workflow: Runs on main branch pushes (version bump + Docker build)"
@echo ""
@echo "Note: CI image approach deprecated due to Gitea Actions workspace mounting"
# Check current database provider
db-status:
@echo "Database Provider: ${DATABASE_PROVIDER}"
@echo "Database URL: ${DATABASE_URL}"
@echo ""
@echo "Current schema.prisma provider:"
grep -A 2 "datasource db" prisma/schema.prisma | head -3