cli icon indicating copy to clipboard operation
cli copied to clipboard

supabase db diff --use-migra generates same grants in all generations

Open terion-name opened this issue 1 year ago • 1 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

supabase db diff --use-migra generates same grants in all generations

To Reproduce

Take migration files from attachments. migrations.zip The problem is already seen there – in last 3 migrations you see the same grants:

grant delete on table "public"."test" to "postgres";
grant insert on table "public"."test" to "postgres";
grant references on table "public"."test" to "postgres";
grant select on table "public"."test" to "postgres";
grant trigger on table "public"."test" to "postgres";
grant truncate on table "public"."test" to "postgres";
grant update on table "public"."test" to "postgres";
grant delete on table "public"."test2" to "postgres";
grant insert on table "public"."test2" to "postgres";
grant references on table "public"."test2" to "postgres";
grant select on table "public"."test2" to "postgres";
grant trigger on table "public"."test2" to "postgres";
grant truncate on table "public"."test2" to "postgres";
grant update on table "public"."test2" to "postgres";

Used script:

{
  "scripts": {
    "db:dump": "dotenv -- cross-var supabase db diff --use-migra -f initial_schema --db-url=%POSTGRES_URL%",
  },
  "devDependencies": {
    "cross-var": "^1.1.0",
    "dotenv-cli": "^7.4.2"
  }
}

Running db:dump multiple times creates new same files

Expected behavior

Grants migrations are not duplicated

System information

  • OS: macOS
  • Version of Node.js: 22.2, but I'm using bun

terion-name avatar Jun 25 '24 15:06 terion-name

It seems that this bug has already been fixed in the latest version of the Supabase CLI.

I wanted to take a look at this, so I tried to reproduce the issue locally by following the steps outlined in the migrations attached to this issue. After running the following command:

npx supabase db diff --use-migra -f initial_schema

on Supabase CLI version 1.191.3, the result was as expected:

No schema changes found

Additionally, after adding an extra column to the "test" table and running the command again, the generated migration contained only the ALTER TABLE instruction, which is the expected behavior.

It appears this issue has been resolved in the newer versions. Could you please confirm if this is also solved on your end so we can close this issue?

avallete avatar Sep 07 '24 11:09 avallete