Skip to content

Fresh DB setup fails due to incomplete Prisma migration history #646

Description

@traitor09

Summary

The repository is missing the initial baseline migrations that create core tables. This issue blocks fresh project setup and affects all new contributors.

Contexts

IN COMMIT 9d85157

The two base migration files that originally initialized the database structure were deleted: -

  1. /migrations/20260312125106_init/migration.sql
    which created the core tables like users, cards, platform_links, etc.
  2. /migrations/20260312162249_analytics_models/migration.sql
    which created card_views and follow_logs

CURRENTLY-
Only remaining migration file in the project - migrations.sql

It was generated to migrate a database that already had the base tables applied.

Expected Behaviour

  • Fresh install should create full database schema successfully using Prisma migrations.

Recommended Fix

  • Creating a single new baseline migration

Restoring the deleted init and analytics_models migrations alone would still leave the database schema inconsistent with schema.prisma.
The schema has evolved (e.g., new Card fields like description, slug, visibility, qrEnabled, viewCount) without corresponding migrations, and these changes are not reflected in any existing migration files.

This would still require manually reconstructing missing SQL changes or dealing with schema drift between Prisma schema and migration history.

Area

backend

Steps to Reproduce & Error Message

See the steps to start backend

❯ npm run db:migrate

> devcard@1.0.0 db:migrate
> npm --prefix apps/backend run db:migrate


> @devcard/backend@1.0.0 db:migrate
> prisma migrate dev

Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "devcard", schema "public" at "localhost:5433"

Error: P3006

Migration `20260617074743_refresh_token_cleanup_indexes` failed to apply cleanly to the shadow database. 
Error code: P1014
Error:
The underlying table for model `users` does not exist.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions