supabase
supabase copied to clipboard
The studio rename or even duplicate the FK when it is updated
Bug report
- [x] I confirm this is a bug with Supabase, not with my own application.
- [x] I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
After upgrading the self hosted version of supabase to the latest: supabase/studio:20240422-5cf8f30
when an existing foreign key is updated, the FK name is updated with a prefix of schema name, or in some cases it does even duplicate the key.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Go to an existing table in supabase studio
- Create a FK on a column by giving it a custom name and save
- Edit the existing FK by updating it's cascading logics
- Et voilà your FK name has been change from
custom_fkey
toschema_custom_fkey
Expected behavior
The studio must just update the existing FK values without changing it's name or duplicating it.
Screenshots
System information
- OS: Ubuntu 20.04.6
- Browser: Chrome
- Version of supabase-js: 2.39.7
- Version of Node.js: 20.10.0
Hey there, running the same version (studio/20240422-5cf8f30
) I am not able to repro:
- create table called
words
with column word astext
- create table called
sentences
with word as a foreign key to theid
columns inwords
- tables are created and FK with name
public_sentences_word_fkey
is made - edit the FK to enable
CASCDE
on update - FK is saved with the same name
However, if you have existing data (i.e. existing FKs with a different name) then editing them will result in the FK being updated to follow the naming convention. I believe this is expected behaviour but the consequences can be problematic so I will raise this to the @supabase/frontend team
Hi @encima, the issue happens exactly when I have some existing data that has been created or imported with a different naming convention on FKs.
Btw I've "resolve" it be renaming all the FKs with the supabase naming convention.
Thanks @nicetomytyuk
We will leave this open as it is a confirmed issue and will be fixed in an upcoming release