Replies: 5 comments 6 replies
-
related #8325 |
Beta Was this translation helpful? Give feedback.
-
So seems the answer here really is why in case 2 and 4 you get this error:
Did you try what happens when you run The error message both times comes from the shadow database whic has a first steps gets all the migration files you have locally applied. One of those commands gives you this error. Do you have Reminder: TimescaleDB is not officially supported, so this being a bit more painful is expected, sorry. |
Beta Was this translation helpful? Give feedback.
-
Sorry for not including the details here, as I posted in #8325 I do use a Timescale Cloud Database for both the db and the shadow-db. So both instances do have the extension pre-installed (currently version 2.5.1) So running There is only one migration file with the extension call at the first line. I noticed that I cannot drop the Extension and activate it in the same session, running
results in the same error as the prisma migration:
I think that the error is caused by the reset prisma does on the shadow database. Also I think that reset is conditional - I guess Prisma checks if a reset is necessary - because if I run Thank you for your support on this! |
Beta Was this translation helpful? Give feedback.
-
@rickbatka Sadly I didn't. Whenever I reset, I run it twice / my script runs it twice for me. |
Beta Was this translation helpful? Give feedback.
-
Quick workaround is to create a package.json script which re-run the commands if it fails the first time: {
"script": {
"migrate:reset": "prisma migrate reset -f || prisma migrate reset -f"
}
}
|
Beta Was this translation helpful? Give feedback.
-
This is a question on how to setup timescale with prisma. Thanks to the post from @janpio I tried to create a similar setup. So this is
related to ##3228
My goal is to ingest IoT data into timescaledb with the help of prisma since the whole raw sql stuff is just bad (I know some stuff will stay raw sql stuff for now, especially timescaledb functionality).
My desired setup
Following the steps
The first step would be to create a migration which will install the timescale extension since the shadow database will run the migrations too (it is obiously already installed on timescale forge). So the
migration.sql
file will look like:CREATE EXTENSION IF NOT EXISTS timescaledb VERSION "2.2.0";
Case 1: Forge Database without shadow database
Try to run the
npx prisma migrate dev
command on the timescale forge database will result in an error since the command tries to create a database:Following the suggestions in #4571 and here: https://www.prisma.io/docs/concepts/components/prisma-migrate#shadow-database the guess would be that it is not possible to use the timescale forge service for the shadow db. Which leads to:
Case 2: Forge database with shadow database on localhost
My localhost is a postgres 13 instance on windows with the timescale extension available.
Adding a shadow database in the environment and running the
npx prisma migrate dev
will result in an error telling that thetimescaledb
extension is already loaded (both instances run 2.2.0):If the timescale forge database has already has data a reset is suggested and if executed will result in:
Case 3 Local Timescale database
If no shadow database is explicitly given (meaning the migrate command will create one) everything works on the local machine (different to Case 1).
Case 4 Local Timescale database with explicit shadow database on the same server
If I explicitly set a shadow database on my local machine I will end up in the same error as Case 2:
Beta Was this translation helpful? Give feedback.
All reactions