Files
myeasycms-v2/apps/web/supabase/tests/database/00000-makerkit-helpers.sql
giancarlo efd27aa7de Update localization texts, add permissions check, and seed data
This commit removes the membersTabDescription, updates the deleteAccountDescription text in the localization files, and adds a condition to check permissions in account invitation component. It also includes test credentials in README and provides a significant amount of seed data for testing the database.
2024-04-20 16:53:54 +08:00

89 lines
1.5 KiB
PL/PgSQL

create schema if not exists makerkit;
-- anon, authenticated, and service_role should have access to makerkit schema
grant USAGE on schema makerkit to anon, authenticated, service_role;
-- Don't allow public to execute any functions in the makerkit schema
alter default PRIVILEGES in schema makerkit revoke execute on FUNCTIONS from public;
-- Grant execute to anon, authenticated, and service_role for testing purposes
alter default PRIVILEGES in schema makerkit grant execute on FUNCTIONS to anon,
authenticated, service_role;
create or replace function makerkit.get_account_by_slug(
account_slug text
)
returns setof accounts
as $$
begin
return query
select
*
from
accounts
where
slug = account_slug;
end;
$$ language PLPGSQL;
create or replace function makerkit.get_account_id_by_slug(
account_slug text
)
returns uuid
as $$
begin
return
(select
id
from
accounts
where
slug = account_slug);
end;
$$ language PLPGSQL;
create or replace function makerkit.get_user_id(
user_email text
)
returns uuid
as $$
begin
return
(select
primary_owner_user_id
from
accounts
where
email = user_email);
end;
$$ language PLPGSQL;
begin;
select plan(1);
select is_empty($$
select
*
from
makerkit.get_account_by_slug('test') $$,
'get_account_by_slug should return an empty set when the account does not exist'
);
select
*
from
finish();
rollback;