Add opinion Tables and request

This commit is contained in:
2020-02-07 02:05:28 +01:00
parent a4dbd43cfb
commit de6ca63165
5 changed files with 163 additions and 0 deletions

View File

@@ -2,6 +2,10 @@
drop table if exists resource_view;
-- Extra resources
drop table if exists opinion_on_article;
drop table if exists opinion;
drop table if exists opinion_list;
drop table if exists follow_article;
drop table if exists follow_constitution;
drop table if exists follow_citizen;

View File

@@ -503,6 +503,32 @@ create table resource_view
ip cidr null
);
create table opinion_list
(
id uuid default uuid_generate_v4() not null primary key,
name text not null,
target text null,
created_at timestamptz default now() not null,
deleted_at timestamptz null
);
create table opinion
(
opinion uuid not null references opinion_list (id),
foreign key (created_by_id) references citizen (id),
primary key (id),
unique (created_by_id, target_id, opinion)
) inherits (extra);
create table opinion_on_article
(
target_reference regclass default 'article'::regclass not null,
foreign key (opinion) references opinion_list (id),
foreign key (target_id) references article (id),
foreign key (created_by_id) references citizen (id),
primary key (id),
unique (created_by_id, target_id, opinion)
) inherits (opinion);
--------------