supabase icon indicating copy to clipboard operation
supabase copied to clipboard

The studio rename or even duplicate the FK when it is updated

Open nicetomytyuk opened this issue 9 months ago • 2 comments

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:

  1. Go to an existing table in supabase studio
  2. Create a FK on a column by giving it a custom name and save
  3. Edit the existing FK by updating it's cascading logics
  4. Et voilà your FK name has been change from custom_fkey to schema_custom_fkey

Expected behavior

The studio must just update the existing FK values without changing it's name or duplicating it.

Screenshots

image image image

System information

  • OS: Ubuntu 20.04.6
  • Browser: Chrome
  • Version of supabase-js: 2.39.7
  • Version of Node.js: 20.10.0

nicetomytyuk avatar May 10 '24 07:05 nicetomytyuk

Hey there, running the same version (studio/20240422-5cf8f30) I am not able to repro:

  1. create table called words with column word as text
  2. create table called sentences with word as a foreign key to the id columns in words
  3. tables are created and FK with name public_sentences_word_fkey is made
  4. edit the FK to enable CASCDE on update
  5. 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

encima avatar Jul 08 '24 09:07 encima

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.

nicetomytyuk avatar Jul 08 '24 09:07 nicetomytyuk

Thanks @nicetomytyuk

We will leave this open as it is a confirmed issue and will be fixed in an upcoming release

encima avatar Jul 19 '24 08:07 encima