I’m trying to import a schema-dump into PostgreSQL with ‘psql -U username -W dbname < migrations/schema.psql’, the Schema is imported partly, but the console throws errors like “ERROR: permission denied for relation table_name” and “ERROR: relation table_name does not exist”.
I’ve created the database like this: “createdb -O username dbname”
There are only 7 tables to import, and it breaks with just importing 3 of them.
Anybody a hint, what to do?
If the backup was in the “custom” format (-Fc), you could use pg_restore instead so you can tell it to not apply ownership changes:
All the objects will created with “username” as the owner.
Barring that, try to grep out the ALTER OWNER and SET SESSION AUTHORIZATION commands into new file (or through send grep output via pipe to psql). Those commands should always be on a single line in the plain-text output format.