-
Notifications
You must be signed in to change notification settings - Fork 0
fix(db): unblock Supabase Preview — add created_by guard in t25 migration #229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
c5f4e49
fa7fdd0
19ed9bb
7b31397
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -321,6 +321,8 @@ EXCEPTION WHEN undefined_table OR undefined_object OR undefined_function THEN NU | |
| END $$; | ||
| DO $$ | ||
| BEGIN | ||
| -- Coluna criada em prod fora do git (Lovable Dashboard). Adiciona se faltar para alinhar Preview/Prod. | ||
| ALTER TABLE public.custom_kits ADD COLUMN IF NOT EXISTS created_by uuid; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The daily Useful? React with 👍 / 👎. |
||
| ALTER POLICY "ck_insert_self" ON public."custom_kits" WITH CHECK (((user_id = (SELECT auth.uid())) OR (created_by = (SELECT auth.uid())))); | ||
| EXCEPTION WHEN undefined_table OR undefined_object OR undefined_function THEN NULL; | ||
| END $$; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
created_byas a client-writable nullable column makes the existingck_insert_selfcheck on the next line effective in fresh databases; an authenticated caller can directly insert acustom_kitsrow withuser_idset to another user's UUID andcreated_byset to their own UUID, satisfying theOR (created_by = auth.uid())branch. Because other policies/key paths useuser_idto select/manage kits, this lets one user create records under another user's ownership unless the column is server-populated or the policy also requiresuser_id = auth.uid().Useful? React with 👍 / 👎.