Closed
Description
Problem
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).
Questions:
- What is the recommended way to do this? I'd like to maintain the multiple statement SQL script independently.
- Can we get typescript support for
simple
method?
Metadata
Metadata
Assignees
Labels
No labels