TimescaleDB: Migration Does Not Work, Yet Works Fine When Run Manually
Author: JRedOWCreated Nov 22, 2021Updated Sep 29, 2026
Labelsbug/1-unconfirmedkind/bugtech/enginestopic: prisma migrate devtopic: postgresqlExtensionstopic: timescaledb
Bug description
I am trying to use Prisma with TimeScaleDB. The sql passes the shadow database and the main database when I run it myself, but throws a weird error when I migrate.
How to reproduce
- Start TimeScaleDB Server With Two Databases (One as the database and another as the shadow database).
- Create Basic Prisma Schema And Connect To TimeScaleDB databases
- Create The Following Migration From Information.
- Run
prisma migrate dev
Expected behavior
Just Converts The Table To A Hypertable with no errors. Instead it throws:
Error: P3018
A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve
Migration name: 20211121045719_score_init
Database error code: 42883
Database error:
ERROR: function create_hypertable(regclass, name) does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Position:
10
11 -- Verify Extention
12 CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
13
14 -- ConvertHypertable
15 SELECT create_hypertable('song_time'::regclass, 'time'::name);
DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState("42883"), message: "function create_hypertable(regclass, name) does not exist", detail: None, hint: Some("No function matches the given name and argument types. You might need to add explicit type casts."), position: Some(Original(354)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("parse_func.c"), line: Some(624), routine: Some("ParseFuncOrColumn") }Prisma information
Migration:
-- CreateTable
CREATE TABLE "song_time" (
"userID" UUID NOT NULL,
"modID" TEXT NOT NULL,
"songID" INTEGER NOT NULL,
"diffID" INTEGER NOT NULL,
"time" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"score" INTEGER NOT NULL
);
-- Verify Extention
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
-- ConvertHypertable
SELECT create_hypertable('song_time'::regclass, 'time'::name);Environment & setup
- OS: Windows 10 (Latest Update)
- Database: TimscaleDB (PostgreSQL with Plugin)
- Node.js version: 16.13.x (Two Different Versions)
Prisma Version
3.5.0Source: prisma/prisma