question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unable to run migrations in an empty PostGIS db

See original GitHub issue

Bug description

Copied from https://github.com/prisma/prisma/discussions/4732

I’m struggling to use the migration tool after I upgraded to 2.13.0. I have a few spatial columns that I manage with scripts besides the Prisma migration tool.

My pipeline used to be this:

  1. apply Prisma migrations
  2. run manual migrations and add / alter spatial columns if needed

but with 2.13.0, I can no longer run any Prisma migration on a fresh PostGIS database because of this error:

Error: P3005

The database schema for `localhost:5432` is not empty. Read more about how to baseline an existing production database: https://pris.ly/d/migrate-baseline

Enabling PostGIS creates a spatial_ref_sys table, so technically the database is not empty, but it should not affect migrations. I know Prisma does not yet support the PostGIS extension, but I’m looking for a workaround.

I’m also a Nexus and nexus-plugin-prisma user which doesn’t support 2.12.x, so I can’t downgrade reliably.

How to reproduce

Steps to reproduce the behavior:

  1. Have an empty PostGIS database (I used https://hub.docker.com/r/postgis/postgis)
  2. Run prisma migrate dev --preview-feature
  3. See error

Expected behavior

Migrations run without an error.

Environment & setup

  • OS: PopOS
  • Database: PostgreSQL with PostGIS
  • Node.js version: v14.13.0
  • Prisma version:
@prisma/cli          : 2.13.0
@prisma/client       : 2.13.0
Current platform     : debian-openssl-1.1.x
Query Engine         : query-engine 833ab05d2a20e822f6736a39a27de4fc8f6b3e49 (at node_modules/@prisma/engines/query-engine-debian-openssl-1.1.x)
Migration Engine     : migration-engine-cli 833ab05d2a20e822f6736a39a27de4fc8f6b3e49 (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core 833ab05d2a20e822f6736a39a27de4fc8f6b3e49 (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary        : prisma-fmt 833ab05d2a20e822f6736a39a27de4fc8f6b3e49 (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Studio               : 0.329.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
tomhoulecommented, Jan 4, 2021

This should be fixed by https://github.com/prisma/prisma-engines/pull/1478, to be released tomorrow.

1reaction
pantharshit00commented, Dec 24, 2020

I can confirm this after running the create extension if not exists "postgis";

I think we should ignore this table

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django migrations failing with fresh database - Stack Overflow
I set up my new database, add it to my settings, and run python manage.py migrate; I get a SQL error telling me...
Read more >
Troubleshooting migration tasks in AWS Database Migration ...
Troubleshoot issues when migrating data using AWS Database Migration ... You can pull data once from a view; you can't use it for...
Read more >
Migration Operations - Django documentation
If you need an empty migration file to write your own Operation objects into, use python manage.py makemigrations --empty yourappname , but be...
Read more >
[Solved]-Unable to apply Django migration in Postgres DB-postgresql
Firstly, Create a migration file to add NULLABLE column without default value. Secondly, Create an empty migration that fill this new empty value...
Read more >
Prisma Migrate limitations and known issues
Run prisma migrate dev to start a new migration history. The last step creates a new initial migration that goes from an empty...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found