Simple migration fails
See original GitHub issueBug description
I’m using Blitz framework with Prisma.
Blitz is using SQLite by default and it worked well but I’ve decided to switch to Postgres.
I’ve deleted the old db migration files, updated configs.
When I run blitz prisma migrate dev
I get the following error:
Environment variables loaded from .env
Prisma schema loaded from db/schema.prisma
Datasource "db": PostgreSQL database "DB_NAME", schema "public" at "127.0.0.1:5432"
Error: db error: ERROR: syntax error at or near "WITH ordinality"
0: sql_migration_connector::flavour::postgres::sql_schema_from_migration_history
at migration-engine/connectors/sql-migration-connector/src/flavour/postgres.rs:354
1: migration_core::api::DevDiagnostic
at migration-engine/core/src/api.rs:108
How to reproduce
See above
Expected behavior
The migration script should create new tables in the DB
Prisma information
schema.prisma
:
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource db {
provider = "postgres"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
// --------------------------------------
model User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String?
email String @unique
hashedPassword String?
role String @default("USER")
tokens Token[]
sessions Session[]
}
model Session {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
expiresAt DateTime?
handle String @unique
hashedSessionToken String?
antiCSRFToken String?
publicData String?
privateData String?
user User? @relation(fields: [userId], references: [id])
userId Int?
}
model Token {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
hashedToken String
type String
// See note below about TokenType enum
// type TokenType
expiresAt DateTime
sentTo String
user User @relation(fields: [userId], references: [id])
userId Int
@@unique([hashedToken, type])
}
env.local
:
DATABASE_URL=postgresql://USER:PASSWORD@127.0.0.1:5432/DB_NAME
Environment & setup
- OS: Ubuntu 14.0
- Database: PostgreSQL 9.3.24
- Node.js version: 16.13.0
Prisma Version
3.5.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Troubleshooting Failed Migrations
A 'failed migration' is when the status of the move request shows as 'failed', and we have one or more failures logged in...
Read more >Migrations – Why do they fail? (12 Worst Practices)
Migrations that are oversold as easy will struggle with expectations, budget, timeline, and resource constraints and will most likely result in ...
Read more >Why does my migration fail?
If you're having difficulty migrating your site due to the migration failing right away, this is the likely cause. Check with your current...
Read more >System Migration Risks: Why System Migrations Fail
1. Poorly understood or undocumented legacy processes · 2. Lack of pre-standardization · 3. Tedious, costly, and subjective process mapping · 4. Incomplete...
Read more >Google Workspace Migration Fails- How to Fix?
Method-1. Migration is Unsuccessful for a Single User. · The email address and SMTP address of the user are correctly written in the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for your replies.
I couldn’t upgrade PostgreSQL because I had a really old Macbook (2011) which had a too old OS, which the latest version of PostgreSQL doesn’t support.
I’ve bought a new Macbook now because I could continue development on the old one. Installed the latest PostgeSQL. The problem is solved.
Yes, it would be good to update the docs and tell about the min. PostgreSQL version requirement.
(Documentation was updated in the meantime: https://www.prisma.io/docs/reference/database-reference/supported-databases)