Skip to content

fix: replace SQLite DATETIME with PostgreSQL TIMESTAMP(3) in init migration - #1002

Merged
ogazboiz merged 2 commits into
LabsCrypt:mainfrom
OpensrcLord:fix/init-migration-postgres-types
Aug 3, 2026
Merged

fix: replace SQLite DATETIME with PostgreSQL TIMESTAMP(3) in init migration#1002
ogazboiz merged 2 commits into
LabsCrypt:mainfrom
OpensrcLord:fix/init-migration-postgres-types

Conversation

@OpensrcLord

@OpensrcLord OpensrcLord commented Jul 27, 2026

Copy link
Copy Markdown

Summary

The init migration (20260221132622_init/migration.sql) was written in SQLite DDL using DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP. Since migration_lock.toml and schema.prisma both declare provider = "postgresql", a fresh prisma migrate deploy against a PostgreSQL database fails immediately with:

type "datetime" does not exist

This blocks all table creation (User, Stream, StreamEvent) on a clean Postgres deploy.

Fix

Replaced all 5 occurrences of DATETIME with TIMESTAMP(3) in the init migration — the correct Prisma-generated column type for DateTime fields on PostgreSQL. No other columns, tables, or indexes were changed.

Changed file

  • backend/prisma/migrations/20260221132622_init/migration.sql

Verification

  • No DATETIME references remain in any migration file
  • Column types now match what Prisma generates for postgresql provider
  • Subsequent migrations (pause fields, IndexerState, unique constraint, indexes) are unaffected
  • Datasource provider remains postgresql

Fixes #828

zeemscript and others added 2 commits July 27, 2026 14:37
…ration

The init migration used DATETIME (SQLite-only) which causes
prisma migrate deploy to fail on PostgreSQL with 'type datetime
does not exist'. Replace all DATETIME columns with TIMESTAMP(3)
to match the postgresql provider in migration_lock.toml and
schema.prisma.

Fixes LabsCrypt#828

@ogazboiz ogazboiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verified: the init migration still had five DATETIME occurrences that valid postgres rejects, so no environment can ever have applied it as written, which makes this rewrite safe by construction. minimal and matches prisma's postgres codegen. merging. if you want to keep contributing, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0

@ogazboiz
ogazboiz merged commit 96824d2 into LabsCrypt:main Aug 3, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backend] init migration uses SQLite DDL (DATETIME, inline PK) - prisma migrate deploy fails on PostgreSQL

3 participants