I am having the following issue:
I have two models, User and Role, everything works fine until I tried to use PostgreSQL database custom schema rather than public . I have the following models:
// User model
class User extends Model {
static table = 'new_schema.users';
static timestamps = true;
static fields = { ... };
static role = () => this.hasOne(Role);
}
// Role model
class Role extends Model {
static table = 'new_schema.roles';
static timestamps = true;
static fields = { ... };
static users = () => this.hasOne(User);
}
Relationships.oneToOne(Role, User);
db.link([Role, User]);
The previous throws error:
error: Uncaught (in promise) PostgresError: relation "new_schema" does not exist
error = new PostgresError(parseNoticeMessage(current_message));
^
at Connection.#simpleQuery (https://deno.land/x/postgres@v0.14.2/connection/connection.ts:626:19)
at async Connection.query (https://deno.land/x/postgres@v0.14.2/connection/connection.ts:875:16)
at async PostgresConnector.query (https://deno.land/x/denodb@v1.1.0/lib/connectors/postgres-connector.ts:76:22)
at async Database.query (https://deno.land/x/denodb@v1.1.0/lib/database.ts:240:21)
at async Function.createTable (https://deno.land/x/denodb@v1.1.0/lib/model.ts:172:5)
at async Database.sync (https://deno.land/x/denodb@v1.1.0/lib/database.ts:210:7)
at async syncDatabase (file:///home/user/my_project/database/db.ts:62:7)
at async file:///home/user/my_project/app.ts:33:24
Note that the tables are created in the correct schema new_schema if we remove relations between models, but it will fail if we setup any relation between models User and Role.
Questions:
Is there any way to setup tables within a custom schema different than default "public"?
What would be the correct way (if any) to use a custom schema for tables in order to get working the relation between models @eveningkid ?
I am having the following issue: I have two models, User and Role, everything works fine until I tried to use PostgreSQL database custom schema rather than
public
. I have the following models:The previous throws error:
Note that the tables are created in the correct schema
new_schema
if we remove relations between models, but it will fail if we setup any relation between modelsUser
andRole
.Questions: Is there any way to setup tables within a custom schema different than default "public"? What would be the correct way (if any) to use a custom schema for tables in order to get working the relation between models @eveningkid ?