declarative schema ignores grants with columns on views
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
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
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
- 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";
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from supabase/cli
-
🐛 Bug supabase/cli
-
🐛 Bug supabase/cli
Difficulty 3/5 1-2 days Newbie friendliness 65/100
-
🐛 Bug supabase/cli
-
🐛 Bug supabase/cli
Difficulty 3/5 1-2 days Newbie friendliness 65/100
-
🐛 Bug supabase/cli
Similar issues
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Crush Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md Open
Difficulty 1/5 Under an hour Newbie friendliness 90/100
ElementsProject/cln-application#167 · 1 comment · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Quantco/pnpm-licenses#17 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100