0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-23 20:33:16 -05:00
logto/packages/schemas/tables/_functions.sql

17 lines
307 B
MySQL
Raw Normal View History

/* init_order = 0.5 */
create function set_tenant_id() returns trigger as
$$ begin
2023-02-10 00:06:52 -05:00
if new.tenant_id is not null then
return new;
end if;
2023-02-10 00:06:52 -05:00
select tenants.id into new.tenant_id
from tenants
where tenants.db_user = current_user;
return new;
end; $$ language plpgsql;
2023-02-08 05:58:45 -05:00
/* no_after_each */