`db remote changes` wants to rename a column to every other column
Bug report
Describe the bug
It seems like my remote db is out of sync with the migrations, though I'm not sure why. When running supabase db remote changes, I get this massive output:
Details
-- This script was generated by the Schema Diff utility in pgAdmin 4
-- For the circular dependencies, the order in which Schema Diff writes the objects is not very sophisticated
-- and may require manual changes to the script to ensure changes are applied in the correct order.
-- Please report an issue for any failure with the reproduction steps.
REVOKE ALL ON TABLE public.customers FROM authenticated;
REVOKE ALL ON TABLE public.customers FROM service_role;
REVOKE ALL ON TABLE public.customers FROM postgres;
GRANT ALL ON TABLE public.customers TO authenticated;
GRANT ALL ON TABLE public.customers TO postgres;
GRANT ALL ON TABLE public.customers TO service_role;
REVOKE ALL ON TABLE public.pages FROM supabase_admin;
REVOKE ALL ON TABLE public.pages FROM authenticated;
REVOKE ALL ON TABLE public.pages FROM anon;
REVOKE ALL ON TABLE public.pages FROM postgres;
REVOKE ALL ON TABLE public.pages FROM service_role;
GRANT ALL ON TABLE public.pages TO anon;
GRANT ALL ON TABLE public.pages TO authenticated;
GRANT ALL ON TABLE public.pages TO postgres;
GRANT ALL ON TABLE public.pages TO service_role;
GRANT ALL ON TABLE public.pages TO supabase_admin;
ALTER TABLE IF EXISTS public.pages
RENAME created_at TO user_id;
ALTER TABLE public.pages
ALTER COLUMN user_id TYPE uuid;
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN user_id DROP DEFAULT;
ALTER TABLE IF EXISTS public.pages
RENAME created_at TO name;
ALTER TABLE public.pages
ALTER COLUMN name TYPE text COLLATE pg_catalog."default";
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN name DROP DEFAULT;
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN name SET STORAGE EXTENDED;
COMMENT ON COLUMN public.pages.name
IS 'Validated with constraint';
ALTER TABLE IF EXISTS public.pages
RENAME created_at TO id;
ALTER TABLE public.pages
ALTER COLUMN id TYPE bigint;
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN id DROP DEFAULT;
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 );
ALTER TABLE IF EXISTS public.pages
RENAME created_at TO branding;
ALTER TABLE public.pages
ALTER COLUMN branding TYPE boolean;
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN branding SET DEFAULT true;
ALTER TABLE IF EXISTS public.pages
RENAME created_at TO google_analytics_key;
ALTER TABLE public.pages
ALTER COLUMN google_analytics_key TYPE text COLLATE pg_catalog."default";
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN google_analytics_key DROP DEFAULT;
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN google_analytics_key DROP NOT NULL;
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN google_analytics_key SET STORAGE EXTENDED;
ALTER TABLE IF EXISTS public.pages
RENAME created_at TO sections;
ALTER TABLE public.pages
ALTER COLUMN sections TYPE jsonb;
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN sections DROP DEFAULT;
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN sections SET STORAGE EXTENDED;
ALTER TABLE IF EXISTS public.pages
RENAME created_at TO title;
ALTER TABLE public.pages
ALTER COLUMN title TYPE text COLLATE pg_catalog."default";
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN title DROP DEFAULT;
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN title SET STORAGE EXTENDED;
ALTER TABLE IF EXISTS public.pages
RENAME created_at TO description;
ALTER TABLE public.pages
ALTER COLUMN description TYPE text COLLATE pg_catalog."default";
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN description SET DEFAULT ''::text;
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN description SET STORAGE EXTENDED;
ALTER TABLE IF EXISTS public.pages
RENAME created_at TO picture;
ALTER TABLE public.pages
ALTER COLUMN picture TYPE text COLLATE pg_catalog."default";
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN picture DROP DEFAULT;
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN picture DROP NOT NULL;
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN picture SET STORAGE EXTENDED;
ALTER TABLE IF EXISTS public.pages
RENAME created_at TO theme;
ALTER TABLE public.pages
ALTER COLUMN theme TYPE integer;
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN theme SET DEFAULT 0;
ALTER TABLE IF EXISTS public.pages
RENAME created_at TO theme_color;
ALTER TABLE public.pages
ALTER COLUMN theme_color TYPE text COLLATE pg_catalog."default";
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN theme_color SET DEFAULT '#dc2626'::text;
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN theme_color SET STORAGE EXTENDED;
ALTER TABLE IF EXISTS public.pages
RENAME created_at TO bg_color;
ALTER TABLE public.pages
ALTER COLUMN bg_color TYPE text COLLATE pg_catalog."default";
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN bg_color SET DEFAULT '#f1f5f9'::text;
ALTER TABLE IF EXISTS public.pages
ALTER COLUMN bg_color SET STORAGE EXTENDED;
I figured there was some column that was missing a NOT NULL or something, but this is quite different.
It starts with these ones where it runs REVOKE ALL and GRANT ALL, which I would assume does nothing:
REVOKE ALL ON TABLE public.customers FROM authenticated;
GRANT ALL ON TABLE public.customers TO authenticated;
-- ...etc
Then it has lots of these, where it tries to rename the created_at column to every other column in the table:
ALTER TABLE IF EXISTS public.pages
RENAME created_at TO user_id;
ALTER TABLE IF EXISTS public.pages
RENAME created_at TO name;
-- ...etc
That makes it pretty hard to tell what's wrong
To Reproduce
Not sure
System information
- OS: macOS
- Version of supabase-js: 1.35.6
- Version of Node.js: 16.15.0
Thanks for informing us of this issue. I will look into adding migra support for remote diff to handle this case.
:tada: This issue has been resolved in version 1.11.2 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
We have added supabase db diff --use-migra --linked flag to diff against linked project in latest version. Let us know if it works so we can default to use migra soon.
@sweatybridge It's outputting No changed found, so I assume it's working and fixed the other there as well (assuming that's expected)!