-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow publishing relocatable and requires package columns
- Loading branch information
Showing
4 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
supabase/migrations/20231110061036_allow_publishing_relocatable_and_requires.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
grant insert (partial_name, handle, control_description, control_relocatable, control_requires) | ||
on app.packages | ||
to authenticated; | ||
|
||
grant update (control_description, control_relocatable, control_requires) | ||
on app.packages | ||
to authenticated; | ||
|
||
create or replace function public.publish_package( | ||
package_name app.valid_name, | ||
package_description varchar(1000), | ||
relocatable bool default false, | ||
requires text[] default '{}' | ||
) | ||
returns void | ||
language plpgsql | ||
as $$ | ||
declare | ||
account app.accounts = account from app.accounts account where id = auth.uid(); | ||
begin | ||
if account.handle is null then | ||
raise exception 'user not logged in'; | ||
end if; | ||
|
||
insert into app.packages(handle, partial_name, control_description, control_relocatable, control_requires) | ||
values (account.handle, package_name, package_description, relocatable, requires) | ||
on conflict on constraint packages_handle_partial_name_key | ||
do update | ||
set control_description = excluded.control_description, | ||
control_relocatable = excluded.control_relocatable, | ||
control_requires = excluded.control_requires; | ||
end; | ||
$$; |