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
Currently, I have two tables, user and groups and I want to associate them in table group2user, where I specify who has which rights to a group table.
Hence, I need two foreign keys in group2user, which should be able to do cascading delete (if we delete the user or group item). However, when I have a look at the tables (see below), I see the cascading delete for group via foreign key user_id.
However, the same does not apply for user_id and group_id in the table group2user, where it is a primary key, but not a foreign key with ON DELETE CASCADE.
Do you know how to fix that?
CREATE TABLE "user" (
user_id VARCHAR NOT NULL,
PRIMARY KEY (user_id)
)
CREATE TABLE "group" (
user_id VARCHAR,
group_id UUID NOT NULL,
PRIMARY KEY (group_id),
FOREIGN KEY(user_id) REFERENCES "user" (user_id) ON DELETE CASCADE
)
CREATE TABLE group2user (
user_id VARCHAR NOT NULL,
group_id UUID NOT NULL,
rights grouprights NOT NULL,
PRIMARY KEY (user_id, group_id)
)
Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.8
Python Version
3.9
Additional Context
No response
The text was updated successfully, but these errors were encountered:
First Check
Commit to Help
Example Code
Description
Currently, I have two tables,
user
andgroups
and I want to associate them in tablegroup2user
, where I specify who has which rights to agroup
table.Hence, I need two foreign keys in
group2user
, which should be able to do cascading delete (if we delete theuser
orgroup
item). However, when I have a look at the tables (see below), I see the cascading delete forgroup
via foreign keyuser_id
.However, the same does not apply for
user_id
andgroup_id
in the tablegroup2user
, where it is a primary key, but not a foreign key withON DELETE CASCADE
.Do you know how to fix that?
Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.8
Python Version
3.9
Additional Context
No response
The text was updated successfully, but these errors were encountered: