Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

declarative schema ignores grants with columns on views

Open
#6,761 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
postgresql, sql, typescript
Domain
cli, database, devtools

Research direction

Look at the declarative schema sync logic in the CLI, likely in a file handling PostgreSQL grants and view parsing. The issue is that column-specific grants on views are not being output. Start by searching for 'GRANT' and 'VIEW' in the codebase, then examine how grants are collected and compared. The test case provided gives a clear reproduction; verify the missing grant statement is generated. Check the output of the sync command against the expected SQL.

Written by the indexing model from the issue text.

Description

bug supabase/cli
Affected area

Database

Supabase CLI version

v2.117.0

Operating system

macOS

Installation method

brew

Command
supabase db schema declarative sync
Actual output
CREATE TABLE "private"."items" (
  "id"        integer NOT NULL,
  "name"      text    NOT NULL,
  "is_active" boolean NOT NULL DEFAULT true,
  CONSTRAINT "items_pkey" PRIMARY KEY (id)
);

CREATE VIEW "api"."items" WITH (security_invoker=true) AS  SELECT id,
    name,
    is_active
   FROM private.items;

GRANT INSERT ("name") ON TABLE "private"."items" TO "authenticated";

GRANT DELETE, INSERT, MAINTAIN, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON TABLE "private"."items" TO "postgres", "service_role";

GRANT DELETE, INSERT, MAINTAIN, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON TABLE "api"."items" TO "postgres", "service_role";
Expected behavior

Output should include the missing grant statement as described in "steps to reproduce" section

GRANT INSERT ("name") ON TABLE "api"."items" TO "authenticated";
Steps to reproduce
  1. Create minimal declaration files:

supabase/database/private/schema.sql

CREATE SCHEMA "private";

GRANT CREATE, USAGE ON SCHEMA "private" TO "postgres";

GRANT USAGE ON SCHEMA "private" TO "service_role", "supabase_auth_admin";

supabase/database/api/schema.sql

CREATE SCHEMA "api";

GRANT USAGE ON SCHEMA "api" TO "authenticated";

GRANT CREATE, USAGE ON SCHEMA "api" TO "postgres";

GRANT USAGE ON SCHEMA "api" TO "service_role";

supabase/database/private/tables/items.sql

CREATE TABLE "private"."items"(
  "id" integer NOT NULL PRIMARY KEY,
  "name" text NOT NULL,
  "is_active" boolean NOT NULL DEFAULT TRUE
);

GRANT DELETE, INSERT, MAINTAIN, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON TABLE "private"."items" TO "postgres", "service_role";

GRANT INSERT ("name") ON TABLE "private"."items" TO "authenticated";

supabase/database/api/views/.sql

CREATE VIEW "api"."items" WITH ( security_invoker = TRUE
) AS
SELECT
  id,
  name,
  is_active
FROM
  private.items;

GRANT DELETE, INSERT, MAINTAIN, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON TABLE "api"."items" TO "postgres", "service_role";

GRANT INSERT ("name") ON TABLE "api"."items" TO "authenticated";
  1. Execute supabase db schema declarative sync
Crash report ID

No response

Docker and service versions

Additional context

No response

Dominant language
TypeScript
Stars
2.4k
Forks
523
Avg merge
1d 1h
Merged PRs (30d)
268

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from supabase/cli

All issues in supabase/cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.