postgresqlquoted-identifier

Postgres: Escape double quote in schema name created by flyway


context: a java app that use flyway to execute db scripts if the schema is empty, connecting via jdbc.

Due to some mistake on my part, I forgot to add the app user as the public schema owner. That led flyway to create a schema with the funny name: "$user", public . Yes, like this. I changed the public owner, relaunch the application ,and that went well, my tables were created.

I just can't figure out how to clean up the schema, and escape the quote and comma in the name. Any idea ? I'm fairly new to postgres.

  \dn
  schemas list
        name       |  owner
   "$user", public | myuser
   public          | myuser
 (2 lines)

Solution

  • To drop that schema, you need to duplicate the quotes - just like you do with single quotes in a String constant:

    drop schema """$user"", public" cascade;