59 lines
1.3 KiB
MySQL
59 lines
1.3 KiB
MySQL
|
-- Deploy camper:surroundings_highlight to pg
|
||
|
-- requires: roles
|
||
|
-- requires: schema_camper
|
||
|
-- requires: company
|
||
|
-- requires: media
|
||
|
-- requires: user_profile
|
||
|
|
||
|
begin;
|
||
|
|
||
|
set search_path to camper, public;
|
||
|
|
||
|
create table surroundings_highlight (
|
||
|
surroundings_highlight_id integer generated by default as identity primary key,
|
||
|
company_id integer not null references company,
|
||
|
media_id integer not null references media,
|
||
|
name text not null constraint name_not_empty check(length(trim(name)) > 0),
|
||
|
description xml not null,
|
||
|
position integer not null default 2147483647
|
||
|
);
|
||
|
|
||
|
grant select on table surroundings_highlight to guest;
|
||
|
grant select on table surroundings_highlight to employee;
|
||
|
grant select, insert, update, delete on table surroundings_highlight to admin;
|
||
|
|
||
|
|
||
|
alter table surroundings_highlight enable row level security;
|
||
|
|
||
|
create policy guest_ok
|
||
|
on surroundings_highlight
|
||
|
for select
|
||
|
using (true)
|
||
|
;
|
||
|
|
||
|
create policy insert_to_company
|
||
|
on surroundings_highlight
|
||
|
for insert
|
||
|
with check (
|
||
|
company_id in (select company_id from user_profile)
|
||
|
)
|
||
|
;
|
||
|
|
||
|
create policy update_company
|
||
|
on surroundings_highlight
|
||
|
for update
|
||
|
using (
|
||
|
company_id in (select company_id from user_profile)
|
||
|
)
|
||
|
;
|
||
|
|
||
|
create policy delete_from_company
|
||
|
on surroundings_highlight
|
||
|
for delete
|
||
|
using (
|
||
|
company_id in (select company_id from user_profile)
|
||
|
)
|
||
|
;
|
||
|
|
||
|
commit;
|