Closed mukulgupta21 closed 6 months ago
I have a use-case where I have a DDL script to initialise the database. Something similar to below:
CREATE DATABASE dbName with owner dbuser ; CREATE TABLE IF NOT EXISTS table ( col1 VARCHAR(255) NOT NULL, col2 VARCHAR(255) NOT NULL, );
I'm trying to use it as below:
await (sql`${sql.unsafe(sqlScript)}` as any).simple();
which results in the following error:
Error creating database PostgresError: CREATE DATABASE cannot run inside a transaction block
EDIT: I realize this is not possible to do in postgresql since one cannot switch a database without re-initializing the connection (aka backend).
simple
Have a look at https://github.com/porsager/postgres/issues/198 – looks like a similar case 👍
Problem
I have a use-case where I have a DDL script to initialise the database. Something similar to below:
I'm trying to use it as below:
which results in the following error:
EDIT: I realize this is not possible to do in postgresql since one cannot switch a database without re-initializing the connection (aka backend).
Questions:
simple
method?