-
Notifications
You must be signed in to change notification settings - Fork 270
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
Running supabase db dump
generates sql that does not cleanly apply on db reset
in certain cases with generated columns
To Reproduce
- Create the following two migration files in supabase/migrations/:
-- 001_initial.sql
SET
default_tablespace = '';
CREATE OR REPLACE FUNCTION "public"."b58encode" ("data" "bytea") RETURNS "text" LANGUAGE "plpgsql" IMMUTABLE STRICT AS $$
BEGIN
RETURN '';
END;
$$;
CREATE OR REPLACE FUNCTION "public"."b58encode" ("data" "uuid") RETURNS "text" LANGUAGE "sql" IMMUTABLE STRICT AS $$
SELECT b58encode(decode(replace(data::text, '-', ''), 'hex'));
$$;
ALTER FUNCTION "public"."b58encode" ("data" "uuid") OWNER TO "postgres";
CREATE TABLE IF NOT EXISTS "public"."example" (
"id" "uuid" DEFAULT 'a62f8a10-683b-4f31-8ec8-3211770ae257'::uuid NOT NULL
);
RESET ALL;
-- 002_bug.sql
ALTER TABLE public.example
ADD COLUMN test text GENERATED ALWAYS AS b58encode (id) STORED;
- Run
supabase db reset
to create the database. - Run
supabase db dump --local --file 001_initial.sql
to create an001_initial.sql
file which reproduces the issue - Remove the two old migration files and replace them with the new
001_initial.sql
file - Run
supabase db reset
again.
What happens:
Resetting local database...
Recreating database...
Initialising schema...
Seeding globals from roles.sql...
Applying migration 001_initial.sql...
ERROR: function b58encode(bytea) does not exist (SQLSTATE 42883)
At statement: 25
CREATE TABLE IF NOT EXISTS "public"."example" (
"id" "uuid" DEFAULT 'a62f8a10-683b-4f31-8ec8-3211770ae257'::"uuid" NOT NULL,
"test" "text" GENERATED ALWAYS AS ("public"."b58encode" ("id")) STORED
)
Try rerunning the command with --debug to troubleshoot the error.
error: "supabase" exited with code 1
Expected behavior
Should generate valid sql.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working