This project follows this Supabase Cascade Delete Discussion
Here are the total number of upvotes github users have commented together on for this discussion: 1.0000e+26
MildTomato: Will move this to 'ideas' in discussion
anngbaum: just wanted to add a +1 and mention that this comes up frequently in discord ([here](https://discord.com/channels/839993398554656828/843999948717555735/966349081515544677) and [here](https://discord.com/channels/839993398554656828/843999948717555735/959744851753173114) to name a few, but searching `on delete cascade` shows a number of examples).
vimtor: I don't know why, but I expected Supabase to delete on cascade by default since it is pretty common in SQL databases. I think it could fit in the cog icon popover or in the slide over when setting up a foreign key relationship 😄
rbkayz: Yes please. This would be great. Having to delete constraint, and add it is a bit cumbersome
codeibrahima: +1 to this
hnrq: +1, definitely need that
bennik88: Would be an important addition!
harryc9: This feature would be amazing!! (esp for me who doesn't want to deal with the SQL side of things ðŸ¤)
ahmedDev20: +1
devj3ns: +1
nenek: +1
Isaac-Harper: +1
jjrise: +1
alexrabin: +100000000000000
VenierGiacomo: +1
JoleMile: +1
hmalkawi1: +12223213232
cdedreuille: Can't agree more. I would love to see that happen. Would make the deleting process so much easier.
RyanTippsTX: Struggling with the same issue right now
RyanTippsTX: or at least allow an option from service role: auth.admin.deleteUser(host_id, { cascade: true, })
hkleine: +1
Ruud14: +1
RyanTippsTX: In Postgres, the ON DELETE CASCADE feature is specified for any foreign key relation in the table schema itself (not as a modifier to a DELETE statement), so the supabase app’s table editor UI might be a more reasonable place to extend this feature to users. On Mon, Nov 7, 2022 at 4:22 AM Ruud Brouwers ***@***.***> wrote: > +1 > > — > Reply to this email directly, view it on GitHub > <https://github.com/supabase/supabase/discussions/6979#discussioncomment-4075052>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AVHTNODFZMROXT4L6HMH4X3WHDJ53ANCNFSM5XLEK5FA> > . > You are receiving this because you commented.Message ID: > ***@***.***> >
othema: +1
bryanherediax: +1
N00nDay: Does anyone have a workaround for this issue? I can't even get `ON CASCADE` working through SQL. I found the snippet below: ``` ALTER TABLE public.join_tags DROP CONSTRAINT join_tags__customer_id_fkey, ADD CONSTRAINT join_tags__customer_id_fkey FOREIGN KEY (id) REFERENCES public.customers(id) ON DELETE CASCADE; ``` but this returns an error that violates the foreign key constraint.
bryanherediax: +10000 for this.
alexgshaw: +1
SlingingCode: +1
alexrabin: Has someone written a script to get the total amount of all the "+1"s & "+10000"s yet? If not I'll get on that asap.
alexrabin: > Has someone written a script to get the total amount of all the "+1"s & "+10000"s yet? > > If not I'll get on that asap. Alrighty, it's up. https://supabase-discussion-tracker.netlify.app
teddarcuri: +42069
alvaroartano: +2506498762
lambou: cascade, restrict, and others
alvaroartano: +9999*99999999**99999999999999
Edo-San: +1!
dave-hay: +1
dougwithseismic: +2023
edymusajev: +1 How is this not a feature? 😅
EskelCz: Please apply this to deleting users from auth
sasweb: +42
rbkayz: A few recommendations: 1. Definitely install [pgAdmin](https://www.pgadmin.org/) - cascade is just one part of what you'll want to maintain. Ideally, other constraints, indexes, etc. are better handled there (till supabase adds options on the console) 2. If you want to set cascade delete to a FK, run this script in your console SQL tab: ``` ALTER TABLE <table_name>DROP CONSTRAINT IF EXISTS <constraint_name> ALTER TABLE <table_name> ADD CONSTRAINT <constraint_name> FOREIGN KEY (<col_name>) REFERENCES other_tbl_name (<other_col_name>) ON DELETE CASCADE; ```
Shenrak: +1 Please...
rubywai: +1
sannajammeh: +1
eialanjones: +1 and counting...
RizanPSTU: +1 please
MattConflitti: +1
StefanVDWeide: This has been open for almost a year now, with mostly "+1" answers. Can anyone maybe shine some light if this feature is on any of the roadmaps? And if so, what timeline are we looking at? Having this built in is infinitely better than rolling my own solution!
benrugg: Just gonna have to keep adding +1's to this...
benrugg: 🔥 For future visitors with this problem, here's a great resource that will give you the exact sql statement you need for your specific table/column names: https://index.garden/a/supabase-cascade/#supabase-delete-cascade
onurusluca: Please!!! +!
arshamg: This is a sorely needed feature. Even better would be one-click ability to turn this on for all tables in `public` schema for `user_id`. I think that is a very common use case (deleting a user and associated records).
gutsyphilip: +1
onurusluca: Good news! It looks like it is being implemented. https://github.com/supabase/supabase/pull/12846
justinwride: This is now live 🚀 I can confirm that I am able to edit any foreign key relation in the UI to select the action for "on delete" https://github.com/supabase/supabase/pull/12846
harryc9: We did it everyone!! 🙌
MildTomato: I can confirm that this is now live and supported in Supabase Studio