mirror of
https://github.com/logto-io/logto.git
synced 2025-02-03 21:48:55 -05:00
15 lines
319 B
MySQL
15 lines
319 B
MySQL
|
/* init_order = 0.5 */
|
||
|
|
||
|
create function set_tenant_id() returns trigger as
|
||
|
$$ begin
|
||
|
select tenants.id into new.tenant_id
|
||
|
from tenants
|
||
|
where ('tenant_user_' || tenants.id) = current_user;
|
||
|
|
||
|
if new.tenant_id is null then
|
||
|
new.tenant_id := 'default';
|
||
|
end if;
|
||
|
|
||
|
return new;
|
||
|
end; $$ language plpgsql;
|