You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 modelclassUserextendsModel{statictable='new_schema.users';statictimestamps=true;staticfields={ ... };staticrole=()=>this.hasOne(Role);}// Role modelclassRoleextendsModel{statictable='new_schema.roles';statictimestamps=true;staticfields={ ... };staticusers=()=>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/[email protected]/connection/connection.ts:626:19)
at async Connection.query (https://deno.land/x/[email protected]/connection/connection.ts:875:16)
at async PostgresConnector.query (https://deno.land/x/[email protected]/lib/connectors/postgres-connector.ts:76:22)
at async Database.query (https://deno.land/x/[email protected]/lib/database.ts:240:21)
at async Function.createTable (https://deno.land/x/[email protected]/lib/model.ts:172:5)
at async Database.sync (https://deno.land/x/[email protected]/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 ?
The text was updated successfully, but these errors were encountered:
osieltorres
changed the title
Not able to use schema different than public in postgres
Unable to use db schema different than public for postgres
Jul 22, 2022
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 ?
The text was updated successfully, but these errors were encountered: