added progress as a future replacement of accept

This commit is contained in:
Jottyfan
2024-10-23 21:33:06 +02:00
parent 66f50a6fe9
commit c135a004f3
124 changed files with 295 additions and 2121 deletions

View File

@ -0,0 +1,6 @@
create type public.enum_progress as enum (
'requested',
'approved',
'rejected',
'revoked'
);

View File

@ -5,6 +5,7 @@ begin;
\i enums/module.sql
\i enums/role.sql
\i enums/sex.sql
\i enums/progress.sql
\i tables/document.sql
\i tables/documentrole.sql

View File

@ -12,6 +12,7 @@ create table public.t_person (
fk_camp integer references public.t_camp(pk),
fk_profile integer references public.t_profile(pk),
accept boolean,
progress public.enum_progress default 'requested',
created timestamp without time zone default now(),
sex public.enum_sex,
fk_registrator integer references public.t_profile(pk),

View File

@ -0,0 +1,14 @@
begin;
\i enums/progress.sql
alter table t_person add column progress public.enum_progress default 'requested';
update t_person set progress = 'approved' where accept = true;
update t_person set progress = 'rejected' where accept = false;
update t_person set progress = 'requested' where accept is null;
\i views/camp.sql
\i views/version.sql
commit;

View File

@ -2,14 +2,14 @@ create or replace view public.v_camp as
with female(used, fk_camp) as (
select count(1), fk_camp
from t_person
where accept = true
where progress = 'approved'
and sex = 'female'
and camprole = 'student'
group by fk_camp
), male(used, fk_camp) as (
select count(1), fk_camp
from t_person
where accept = true
where progress = 'approved'
and sex = 'male'
and camprole = 'student'
group by fk_camp