ERROR: no schema has been selected to create in
See original GitHub issueBug description
When running npx prisma migrate dev for the 2nd time I get this error
Environment variables loaded from ../.env
Prisma schema loaded from schema.prisma
Datasource "db": PostgreSQL database "test-dev", schema "public" at "test-dev.postgres.database.azure.com:5432"
Error: P3006
Migration `20210930002201_init` failed to apply cleanly to the shadow database. 
Error:
db error: ERROR: no schema has been selected to create in
   0: sql_migration_connector::flavour::postgres::sql_schema_from_migration_history
             at migration-engine/connectors/sql-migration-connector/src/flavour/postgres.rs:373
   1: migration_core::api::DevDiagnostic
             at migration-engine/core/src/api.rs:93
How to reproduce
- create a schema file with shadowDatabaseUrl
- run npx prisma migrate dev, tables gets created, migration gets created
- run npx prisma migrate devagain. you encounter the error above
Expected behavior
- it should either create a new migration file if there are changes or return with no errors
Prisma information
generator client {
  provider = "prisma-client-js"
  output = "../src/db/prisma"
}
datasource db {
  provider = "postgresql"
  url      = env("CONN_STRING")
  shadowDatabaseUrl = env("SHADOW_DB_URL")
}
model feeds {
  id      Int     @id @default(autoincrement())
  title   String? @db.VarChar(255)
  rss_url String? @db.VarChar(255)
  colour  String? @db.VarChar(255)
}
model sessions {
  sid    String   @id(map: "session_pkey") @db.VarChar
  sess   Json     @db.Json
  expire DateTime @db.Timestamp(6)
  @@index([expire], map: "IDX_session_expire")
}
model users {
  id              Int       @id @default(autoincrement())
  email           String    @unique(map: "users_email_unique") @db.VarChar(255)
  password        String
  role            String
  rss_url         String?
  credentials     String?
  title           String?
  city            String?
  prov_state      String?
  country         String?
  first_name      String?
  middle_name     String?
  last_name       String?
  show_email      Boolean?  @default(false)
  notes           String?
  unsubscribe     Boolean?  @default(false)
  last_sign_in_at DateTime? @db.Timestamptz(6)
  created_at      DateTime  @default(now()) @db.Timestamptz(6)
  updated_at      DateTime  @updatedAt
}
Environment & setup
- OS: Windows (WSL Ubuntu 20.04)
- Database: PostgreSQL (Azure)
- Node.js version: v14.17.4
Prisma Version
 0.423.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
 Top Results From Across the Web
Top Results From Across the Web
ERROR: no schema has been selected to create in
When a user has USAGE privilege, but lacks CREATE privilege on the schema, it's a different error when trying to create an object:...
Read more >python - No schema has been selected to create in ... error
You get this error when your search_path setting has no valid first entry (typically empty). Postgres does not know in which schema to...
Read more >PostgreSQL: no schema has been selected to create in #16315
Error while trying to create admin user: An exception occurred while executing 'CREATE TABLE oc_migrations (app VARCHAR(255) NOT NULL, ...
Read more >no schema has been selected to create in - SonarQube
PSQLException: ERROR: no schema has been selected to create in Position: 14 at org.postgresql.core.v3.QueryExecutorImpl.
Read more >ERROR: no schema has been selected to create in ... - YouTube
Databases: ERROR : no schema has been selected to create inHelpful? Please support me on Patreon: https://www.patreon.com/roelvandepaarWith ...
Read more > Top Related Medium Post
Top Related Medium Post
No results found
 Top Related StackOverflow Question
Top Related StackOverflow Question
No results found
 Troubleshoot Live Code
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free Top Related Reddit Thread
Top Related Reddit Thread
No results found
 Top Related Hackernoon Post
Top Related Hackernoon Post
No results found
 Top Related Tweet
Top Related Tweet
No results found
 Top Related Dev.to Post
Top Related Dev.to Post
No results found
 Top Related Hashnode Post
Top Related Hashnode Post
No results found

At least for me the issue seems to be with postgresql hosted on azure, running the action against the database on azure resulted on the same error:
Running a container locally did work:
For anyone having the same issue I found this stackoverflow thread that solved it for me: https://stackoverflow.com/questions/41207259/no-schema-has-been-selected-to-create-in-error#:~:text=You get this error when,users ).
As in that thread granting create and usage permissions on the public schema had the migrations working for me again:
grant usage on schema public to public; grant create on schema public to public;