campingmontagut/deploy/surroundings_highlight.sql
jordi fita mas a0f9c10193 Add management of surroundings’ highlights (points of interest)
Customer does not want the new “masonry-like” design of the surroundings
page, and wants the same style they already had: a regular list with
text and photo, alternating the photo’s side.

And, of course, they want to be able to add and edit them themselves. It
is like another carousel, but with an additional rich-text description.

The photos that we had in that page are no longer of use.
2024-01-16 01:26:35 +01:00

59 lines
1.3 KiB
PL/PgSQL

-- 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;