Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate dev and PostGis Views #7764

Closed
zigzactly opened this issue Jun 19, 2021 · 6 comments · Fixed by prisma/prisma-engines#2083
Closed

migrate dev and PostGis Views #7764

zigzactly opened this issue Jun 19, 2021 · 6 comments · Fixed by prisma/prisma-engines#2083
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: postgis
Milestone

Comments

@zigzactly
Copy link

zigzactly commented Jun 19, 2021

Bug description

Hi there, i am having difficulties running prisma migrate dev on a postgres db with postgis installed.

Looking at past issues with PostGis (#4745), spatial_ref_sys looks like is properly ignored now. But i also have in my database "geometry_columns" and "geography_columns" views which prisma migrate cannot seem to do anything about.

Error: P3016

The fallback method for database resets failed, meaning Migrate could not clean up the database entirely. Original error:
Database error
Error querying the database: db error: ERROR: cannot drop view geography_columns because extension postgis requires it
HINT: You can drop extension postgis instead.
   0: sql_migration_connector::best_effort_reset
           with connection=<connection details>
             at migration-engine/connectors/sql-migration-connector/src/lib.rs:100
   1: migration_core::api::Reset
             at migration-engine/core/src/api.rs:159

Unfortunately i cannot remove the PostGis extension. (ps. i am new to postgis and it is also possible that i have configured PostGis wrongly, as there doesnt seem to be anyone with the same issue)

Is there any place i can define a list of ignored tables / views for migrate?

How to reproduce

  1. With PostGis and related views enabled in database
  2. Run prisma migrate dev

Expected behavior

No response

Prisma information

Running prisma migrate dev --name init

Environment & setup

  • OS: Mac OS
  • Database: PostgreSQL
  • Node.js version: 14.4.0

Prisma Version

"@prisma/client": "^2.25.0"
"prisma": "^2.25.0"
@zigzactly zigzactly added the kind/bug A reported bug. label Jun 19, 2021
@janpio janpio changed the title MIgrate Dev and PostGis Views migrate dev and PostGis Views Jun 19, 2021
@janpio janpio added the team/schema Issue for team Schema. label Jun 19, 2021
@pantharshit00
Copy link
Contributor

pantharshit00 commented Jun 21, 2021

We can add more exceptions in migrate. Thanks for raising this.

@pantharshit00 pantharshit00 added the bug/2-confirmed Bug has been reproduced and confirmed. label Jun 21, 2021
@tomhoule tomhoule self-assigned this Jun 30, 2021
@tomhoule tomhoule added this to the 2.27.0 milestone Jun 30, 2021
@tomhoule
Copy link
Contributor

tomhoule commented Jul 8, 2021

Ok I researched this and geometry_columns and spatial_ref_sys used to be tables, but they are views in newer versions of postgis. We have code to ignore these, it just needs to be extended to views. Working on this.

tomhoule added a commit to prisma/prisma-engines that referenced this issue Jul 8, 2021
spatial_ref_sys and geometry_columns used to be tables managed by
postgis, and in more recent versions they are views managed by postgis.
We make sure to ignore them in both cases.

closes prisma/prisma#7764
tomhoule added a commit to prisma/prisma-engines that referenced this issue Jul 8, 2021
spatial_ref_sys and geometry_columns used to be tables managed by
postgis, and in more recent versions they are views managed by postgis.
We make sure to ignore them in both cases.

closes prisma/prisma#7764
@capaj
Copy link

capaj commented Jul 4, 2022

@tomhoule was this released? I am getting this error on prisma 4.0.0

Error: P3016

The fallback method for database resets failed, meaning Migrate could not clean up the database entirely. Original error: 
db error: ERROR: cannot drop view geography_columns because extension postgis requires it
HINT: You can drop extension postgis instead.
   0: sql_migration_connector::best_effort_reset
             at migration-engine/connectors/sql-migration-connector/src/lib.rs:288
   1: migration_core::state::Reset
             at migration-engine/core/src/state.rs:341

@capaj
Copy link

capaj commented Jul 4, 2022

Should I open a new issue or can you reopen this one @tomhoule ?

@tomhoule
Copy link
Contributor

tomhoule commented Jul 4, 2022

@capaj please open a new issue, it's a different view from those that were in the postgis docs we based the fix on (https://postgis.net/docs/manual-1.4/ch04.html#id41859)

@capaj
Copy link

capaj commented Jul 6, 2022

created as #14182

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: postgis
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants