#Prisma ORM: Renaming a table/model when using database schemas

3 messages · Page 1 of 1 (latest)

merry yarrow
#

Hi all! I am trying to rewrite a Prisma migration file in order to rename one of the models/tables. I think I have the syntax wrong possibly, because I am using database schemas, aka namespaces, and I think this syntax is wrong. Any suggestions?

Desired change: rename the model from Biller to User (I will also want to rename the schema itself but that's less important for now)

Existing schema file:

model Biller {
...

  @@schema("biller")
}

Custom migration script:

ALTER TABLE IF EXISTS "biller"."Biller" RENAME "biller"."Biller" to "biller"."User";

Error received upon attempting to apply migration:

Migration `20240327191753_change_biller_to_user_and_add_fields` failed to apply cleanly to the shadow database.
Error:
ERROR: syntax error at or near "."
   0: sql_schema_connector::validate_migrations
           with namespaces=Some(Namespaces("myapp", ["biller"]))
dense wolf
merry yarrow