update postgresjson
This commit is contained in:
@@ -5,7 +5,7 @@ declare
|
||||
begin
|
||||
delete from follow;
|
||||
|
||||
insert into follow_article (id, citizen_id, target_id)
|
||||
insert into follow_article (id, created_by_id, target_id)
|
||||
select
|
||||
uuid_in(md5('follow_article'||row_number() over ())::cstring),
|
||||
z.id,
|
||||
@@ -13,7 +13,7 @@ begin
|
||||
from (select *, row_number() over () % (article_count+7) rn from citizen, lateral generate_series(1, 5)) z
|
||||
join (select *, row_number() over () rn from article) a using (rn);
|
||||
|
||||
insert into follow_constitution (id, citizen_id, target_id)
|
||||
insert into follow_constitution (id, created_by_id, target_id)
|
||||
select
|
||||
uuid_in(md5('follow_constitution'||row_number() over ())::cstring),
|
||||
z.id,
|
||||
@@ -21,7 +21,7 @@ begin
|
||||
from (select *, row_number() over () % (article_count+7) rn from citizen, lateral generate_series(1, 5)) z
|
||||
join (select *, row_number() over () rn from constitution) a using (rn);
|
||||
|
||||
insert into follow_citizen (id, citizen_id, target_id)
|
||||
insert into follow_citizen (id, created_by_id, target_id)
|
||||
select
|
||||
uuid_in(md5('follow_citizen'||row_number() over ())::cstring),
|
||||
z.id,
|
||||
|
||||
@@ -5,7 +5,7 @@ declare
|
||||
begin
|
||||
delete from comment;
|
||||
|
||||
insert into comment_on_article (id, citizen_id, target_id, content)
|
||||
insert into comment_on_article (id, created_by_id, target_id, content)
|
||||
select
|
||||
uuid_in(md5('comment_on_article'||row_number() over ())::cstring),
|
||||
z.id,
|
||||
@@ -14,7 +14,7 @@ begin
|
||||
from (select *, row_number() over () % (article_count+7) rn from citizen, lateral generate_series(1, 5) g) z
|
||||
join (select *, row_number() over () rn from article) a using (rn);
|
||||
|
||||
insert into comment_on_article (id, citizen_id, target_id, content, parent_id)
|
||||
insert into comment_on_article (id, created_by_id, target_id, content, parent_id)
|
||||
select
|
||||
uuid_in(md5('comment_on_article_2'||row_number() over ())::cstring),
|
||||
z.id,
|
||||
@@ -24,7 +24,7 @@ begin
|
||||
from (select *, row_number() over () % (article_count+7) rn from citizen, lateral generate_series(1, 5) g) z
|
||||
join (select *, row_number() over () rn from comment_on_article) a using (rn);
|
||||
|
||||
insert into comment_on_article (id, citizen_id, target_id, content, parent_id)
|
||||
insert into comment_on_article (id, created_by_id, target_id, content, parent_id)
|
||||
select
|
||||
uuid_in(md5('comment_on_article_3'||row_number() over ())::cstring),
|
||||
z.id,
|
||||
@@ -34,7 +34,7 @@ begin
|
||||
from (select *, row_number() over () % (article_count+7) rn from citizen, lateral generate_series(1, 5) g) z
|
||||
join (select *, row_number() over () rn from comment_on_article where parent_id is not null) a using (rn);
|
||||
|
||||
insert into comment_on_constitution (id, citizen_id, target_id, content)
|
||||
insert into comment_on_constitution (id, created_by_id, target_id, content)
|
||||
select
|
||||
uuid_in(md5('comment_on_constitution'||row_number() over ())::cstring),
|
||||
z.id,
|
||||
|
||||
@@ -8,7 +8,7 @@ begin
|
||||
delete from vote_for_comment_on_article;
|
||||
delete from vote_for_comment_on_constitution;
|
||||
raise notice '%', article_count;
|
||||
insert into vote_for_article (id, citizen_id, target_id, note, anonymous)
|
||||
insert into vote_for_article (id, created_by_id, target_id, note, anonymous)
|
||||
select
|
||||
uuid_in(md5('vote_for_article'||row_number() over ())::cstring),
|
||||
z.id,
|
||||
@@ -18,7 +18,7 @@ raise notice '%', article_count;
|
||||
from (select *, row_number() over ()+g % (article_count+7) rn, g from citizen, lateral generate_series(1, 5) g) z
|
||||
join (select *, row_number() over () rn from article) a using (rn);
|
||||
|
||||
insert into vote_for_constitution (id, citizen_id, target_id, note, anonymous)
|
||||
insert into vote_for_constitution (id, created_by_id, target_id, note, anonymous)
|
||||
select
|
||||
uuid_in(md5('vote_for_constitution'||row_number() over ())::cstring),
|
||||
z.id,
|
||||
@@ -28,7 +28,7 @@ raise notice '%', article_count;
|
||||
from (select *, row_number() over () % (article_count+7) rn, g from citizen, lateral generate_series(1, 5) g) z
|
||||
join (select *, row_number() over () rn from constitution) a using (rn);
|
||||
|
||||
insert into vote_for_comment_on_article (id, citizen_id, target_id, note, anonymous)
|
||||
insert into vote_for_comment_on_article (id, created_by_id, target_id, note, anonymous)
|
||||
select
|
||||
uuid_in(md5('vote_for_comment_on_article'||row_number() over ())::cstring),
|
||||
z.id,
|
||||
@@ -38,7 +38,7 @@ raise notice '%', article_count;
|
||||
from (select *, row_number() over () % (article_count+7) rn, g from citizen, lateral generate_series(1, 3) g) z
|
||||
join (select *, row_number() over () rn from comment_on_article) a using (rn);
|
||||
|
||||
insert into vote_for_comment_on_constitution (id, citizen_id, target_id, note, anonymous)
|
||||
insert into vote_for_comment_on_constitution (id, created_by_id, target_id, note, anonymous)
|
||||
select
|
||||
uuid_in(md5('vote_for_comment_on_constitution'||row_number() over ())::cstring),
|
||||
z.id,
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
create or replace function comment(reference regclass, target_id uuid, citizen_id uuid, content text, parent_id uuid default null, out id uuid)
|
||||
create or replace function comment(reference regclass, target_id uuid, created_by_id uuid, content text, parent_id uuid default null, out id uuid)
|
||||
language plpgsql as
|
||||
$$
|
||||
declare
|
||||
_citizen_id alias for citizen_id;
|
||||
_created_by_id alias for created_by_id;
|
||||
_target_id alias for target_id;
|
||||
_content alias for content;
|
||||
_parent_id alias for parent_id;
|
||||
_id alias for id;
|
||||
begin
|
||||
if reference = 'article'::regclass then
|
||||
insert into comment_on_article (citizen_id, target_id, content, parent_id)
|
||||
values (_citizen_id, _target_id, _content, _parent_id)
|
||||
insert into comment_on_article (created_by_id, target_id, content, parent_id)
|
||||
values (_created_by_id, _target_id, _content, _parent_id)
|
||||
returning comment_on_article.id into _id;
|
||||
elseif reference = 'constitution'::regclass then
|
||||
insert into comment_on_constitution (citizen_id, target_id, content, parent_id)
|
||||
values (_citizen_id, _target_id, _content, _parent_id)
|
||||
insert into comment_on_constitution (created_by_id, target_id, content, parent_id)
|
||||
values (_created_by_id, _target_id, _content, _parent_id)
|
||||
returning comment_on_constitution.id into _id;
|
||||
else
|
||||
raise exception 'comment with target as "%", is no implemented', reference::text;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
create or replace function find_comment_by_id(
|
||||
_id uuid,
|
||||
out resource json
|
||||
) language plpgsql as
|
||||
$$
|
||||
begin
|
||||
select to_json(t)
|
||||
into resource
|
||||
from (
|
||||
select
|
||||
com.*,
|
||||
json_build_object('id', com.target_id) as target,
|
||||
find_citizen_by_id(com.created_by_id) as created_by
|
||||
from "comment" as com
|
||||
where id = _id
|
||||
) as t;
|
||||
end;
|
||||
$$;
|
||||
|
||||
-- drop function if exists find_comment_by_id(uuid, out json);
|
||||
@@ -1,5 +1,5 @@
|
||||
create or replace function find_comments_article_by_citizen(
|
||||
_citizen_id uuid,
|
||||
_created_by_id uuid,
|
||||
"limit" int default 50,
|
||||
"offset" int default 0,
|
||||
out resource json,
|
||||
@@ -13,9 +13,9 @@ begin
|
||||
select
|
||||
com.*,
|
||||
find_article_by_id(com.target_id) as target,
|
||||
find_citizen_by_id(com.citizen_id) as citizen
|
||||
find_citizen_by_id(com.created_by_id) as created_by
|
||||
from comment as com
|
||||
where citizen_id = _citizen_id
|
||||
where created_by_id = _created_by_id
|
||||
and target_reference = 'article'::regclass
|
||||
order by created_at desc,
|
||||
com.created_at desc
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
create or replace function find_comments_by_citizen(
|
||||
_citizen_id uuid,
|
||||
_created_by_id uuid,
|
||||
"limit" int default 50,
|
||||
"offset" int default 0,
|
||||
out resource json,
|
||||
@@ -7,15 +7,15 @@ create or replace function find_comments_by_citizen(
|
||||
) language plpgsql as
|
||||
$$
|
||||
begin
|
||||
select json_agg(t), (select count(id) from "comment" where citizen_id = _citizen_id)
|
||||
select json_agg(t), (select count(id) from "comment" where created_by_id = _created_by_id)
|
||||
into resource, total
|
||||
from (
|
||||
select
|
||||
com.*,
|
||||
json_build_object('id', com.target_id) as target,
|
||||
find_citizen_by_id(com.citizen_id) as citizen
|
||||
find_citizen_by_id(com.created_by_id) as created_by
|
||||
from "comment" as com
|
||||
where citizen_id = _citizen_id
|
||||
where created_by_id = _created_by_id
|
||||
order by created_at desc,
|
||||
com.created_at desc
|
||||
limit "limit" offset "offset"
|
||||
|
||||
@@ -13,7 +13,7 @@ begin
|
||||
select
|
||||
com.*,
|
||||
json_build_object('id', com.target_id) as target,
|
||||
find_citizen_by_id(com.citizen_id) as citizen
|
||||
find_citizen_by_id(com.created_by_id) as created_by
|
||||
from "comment" as com
|
||||
where com.parents_ids @> array[_parent_id]
|
||||
order by com.parents_ids nulls first, created_at desc,
|
||||
|
||||
@@ -13,7 +13,7 @@ begin
|
||||
select
|
||||
com.*,
|
||||
json_build_object('id', com.target_id) as target,
|
||||
find_citizen_by_id(com.citizen_id) as citizen
|
||||
find_citizen_by_id(com.created_by_id) as created_by
|
||||
from "comment" as com
|
||||
where com.target_id = _target_id
|
||||
order by com.parents_ids nulls first, created_at desc,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
create or replace function find_comments_constitution_by_citizen(
|
||||
_citizen_id uuid,
|
||||
_created_by_id uuid,
|
||||
"limit" int default 50,
|
||||
"offset" int default 0,
|
||||
out resource json,
|
||||
@@ -13,9 +13,9 @@ begin
|
||||
select
|
||||
com.*,
|
||||
find_constitution_by_id(com.target_id) as target,
|
||||
find_citizen_by_id(com.citizen_id) as citizen
|
||||
find_citizen_by_id(com.created_by_id) as created_by
|
||||
from comment as com
|
||||
where citizen_id = _citizen_id
|
||||
where created_by_id = _created_by_id
|
||||
and target_reference = 'constitution'::regclass
|
||||
order by created_at desc,
|
||||
com.created_at desc
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
create or replace function find_follows_article_by_citizen(
|
||||
_citizen_id uuid,
|
||||
_created_by_id uuid,
|
||||
"limit" int default 50,
|
||||
"offset" int default 0,
|
||||
out resource json,
|
||||
@@ -13,9 +13,9 @@ begin
|
||||
select
|
||||
f.*,
|
||||
find_article_by_id(f.target_id) as target,
|
||||
find_citizen_by_id(f.citizen_id) as citizen
|
||||
find_citizen_by_id(f.created_by_id) as created_by
|
||||
from follow as f
|
||||
where citizen_id = _citizen_id
|
||||
where created_by_id = _created_by_id
|
||||
order by created_at desc,
|
||||
f.created_at desc
|
||||
limit "limit" offset "offset"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
create or replace function find_follows_by_citizen(
|
||||
_citizen_id uuid,
|
||||
_created_by_id uuid,
|
||||
"limit" int default 50,
|
||||
"offset" int default 0,
|
||||
out resource json,
|
||||
@@ -13,9 +13,9 @@ begin
|
||||
select
|
||||
f.*,
|
||||
json_build_object('id', f.target_id) as target,
|
||||
find_citizen_by_id(f.citizen_id) as citizen
|
||||
find_citizen_by_id(f.created_by_id) as created_by
|
||||
from follow as f
|
||||
where citizen_id = _citizen_id
|
||||
where created_by_id = _created_by_id
|
||||
order by created_at desc,
|
||||
f.created_at desc
|
||||
limit "limit" offset "offset"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
create or replace function find_follows_constitution_by_citizen(
|
||||
_citizen_id uuid,
|
||||
_created_by_id uuid,
|
||||
"limit" int default 50,
|
||||
"offset" int default 0,
|
||||
out resource json,
|
||||
@@ -13,9 +13,9 @@ begin
|
||||
select
|
||||
f.*,
|
||||
find_constitution_by_id(f.target_id) as target,
|
||||
find_citizen_by_id(f.citizen_id) as citizen
|
||||
find_citizen_by_id(f.created_by_id) as created_by
|
||||
from follow as f
|
||||
where citizen_id = _citizen_id
|
||||
where created_by_id = _created_by_id
|
||||
order by created_at desc,
|
||||
f.created_at desc
|
||||
limit "limit" offset "offset"
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
create or replace function follow(reference regclass, _target_id uuid, _citizen_id uuid) returns void
|
||||
create or replace function follow(reference regclass, _target_id uuid, _created_by_id uuid) returns void
|
||||
language plpgsql as
|
||||
$$
|
||||
begin
|
||||
if reference = 'article'::regclass then
|
||||
insert into follow_article (citizen_id, target_id)
|
||||
values (_citizen_id, _target_id)
|
||||
on conflict (citizen_id, target_id) do nothing;
|
||||
insert into follow_article (created_by_id, target_id)
|
||||
values (_created_by_id, _target_id)
|
||||
on conflict (created_by_id, target_id) do nothing;
|
||||
elseif reference = 'constitution'::regclass then
|
||||
insert into follow_constitution (citizen_id, target_id)
|
||||
values (_citizen_id, _target_id)
|
||||
on conflict (citizen_id, target_id) do nothing;
|
||||
insert into follow_constitution (created_by_id, target_id)
|
||||
values (_created_by_id, _target_id)
|
||||
on conflict (created_by_id, target_id) do nothing;
|
||||
elseif reference = 'citizen'::regclass then
|
||||
insert into follow_citizen (citizen_id, target_id)
|
||||
values (_citizen_id, _target_id)
|
||||
on conflict (citizen_id, target_id) do nothing;
|
||||
insert into follow_citizen (created_by_id, target_id)
|
||||
values (_created_by_id, _target_id)
|
||||
on conflict (created_by_id, target_id) do nothing;
|
||||
else
|
||||
raise exception '% no implemented', reference::text;
|
||||
end if;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
create or replace function unfollow(reference regclass, _target_id uuid, _citizen_id uuid) returns void
|
||||
create or replace function unfollow(reference regclass, _target_id uuid, _created_by_id uuid) returns void
|
||||
language plpgsql as
|
||||
$$
|
||||
begin
|
||||
delete
|
||||
from follow f
|
||||
where f.citizen_id = _citizen_id
|
||||
where f.created_by_id = _created_by_id
|
||||
and f.target_id = _target_id
|
||||
and f.target_reference = reference;
|
||||
end;
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
create or replace function vote(reference regclass, _target_id uuid, _citizen_id uuid, _note int, _anonymous bool default true) returns void
|
||||
create or replace function vote(reference regclass, _target_id uuid, _created_by_id uuid, _note int, _anonymous bool default true) returns void
|
||||
language plpgsql as
|
||||
$$
|
||||
begin
|
||||
if reference = 'article'::regclass then
|
||||
insert into vote_for_article (citizen_id, target_id, note, anonymous)
|
||||
values (_citizen_id, _target_id, _note, _anonymous)
|
||||
on conflict (citizen_id, target_id) do update set
|
||||
insert into vote_for_article (created_by_id, target_id, note, anonymous)
|
||||
values (_created_by_id, _target_id, _note, _anonymous)
|
||||
on conflict (created_by_id, target_id) do update set
|
||||
note = excluded.note,
|
||||
anonymous = excluded.anonymous;
|
||||
elseif reference = 'constitution'::regclass then
|
||||
insert into vote_for_constitution (citizen_id, target_id, note, anonymous)
|
||||
values (_citizen_id, _target_id, _note, _anonymous)
|
||||
on conflict (citizen_id, target_id) do update set
|
||||
insert into vote_for_constitution (created_by_id, target_id, note, anonymous)
|
||||
values (_created_by_id, _target_id, _note, _anonymous)
|
||||
on conflict (created_by_id, target_id) do update set
|
||||
note = excluded.note,
|
||||
anonymous = excluded.anonymous;
|
||||
elseif reference = 'comment_on_article'::regclass then
|
||||
insert into vote_for_comment_on_article (citizen_id, target_id, note, anonymous)
|
||||
values (_citizen_id, _target_id, _note, _anonymous)
|
||||
on conflict (citizen_id, target_id) do update set
|
||||
insert into vote_for_comment_on_article (created_by_id, target_id, note, anonymous)
|
||||
values (_created_by_id, _target_id, _note, _anonymous)
|
||||
on conflict (created_by_id, target_id) do update set
|
||||
note = excluded.note,
|
||||
anonymous = excluded.anonymous;
|
||||
elseif reference = 'comment_on_constitution'::regclass then
|
||||
insert into vote_for_comment_on_constitution (citizen_id, target_id, note, anonymous)
|
||||
values (_citizen_id, _target_id, _note, _anonymous)
|
||||
on conflict (citizen_id, target_id) do update set
|
||||
insert into vote_for_comment_on_constitution (created_by_id, target_id, note, anonymous)
|
||||
values (_created_by_id, _target_id, _note, _anonymous)
|
||||
on conflict (created_by_id, target_id) do update set
|
||||
note = excluded.note,
|
||||
anonymous = excluded.anonymous;
|
||||
else
|
||||
|
||||
@@ -186,43 +186,43 @@ create table extra
|
||||
(
|
||||
id uuid default uuid_generate_v4() not null primary key,
|
||||
created_at timestamptz default now() not null,
|
||||
citizen_id uuid not null references citizen (id),
|
||||
created_by_id uuid not null references citizen (id),
|
||||
target_id uuid not null,
|
||||
target_reference regclass not null
|
||||
);
|
||||
|
||||
create table follow
|
||||
(
|
||||
foreign key (citizen_id) references citizen (id),
|
||||
foreign key (created_by_id) references citizen (id),
|
||||
primary key (id),
|
||||
unique (citizen_id, target_id)
|
||||
unique (created_by_id, target_id)
|
||||
) inherits (extra);
|
||||
|
||||
create table follow_article
|
||||
(
|
||||
target_reference regclass default 'article'::regclass not null,
|
||||
foreign key (citizen_id) references citizen (id),
|
||||
foreign key (created_by_id) references citizen (id),
|
||||
foreign key (target_id) references article (id),
|
||||
primary key (id),
|
||||
unique (citizen_id, target_id)
|
||||
unique (created_by_id, target_id)
|
||||
) inherits (follow);
|
||||
|
||||
create table follow_constitution
|
||||
(
|
||||
target_reference regclass default 'constitution'::regclass not null,
|
||||
foreign key (citizen_id) references citizen (id),
|
||||
foreign key (created_by_id) references citizen (id),
|
||||
foreign key (target_id) references constitution (id),
|
||||
primary key (id),
|
||||
unique (citizen_id, target_id)
|
||||
unique (created_by_id, target_id)
|
||||
) inherits (follow);
|
||||
|
||||
create table follow_citizen
|
||||
(
|
||||
target_reference regclass default 'citizen'::regclass not null,
|
||||
foreign key (citizen_id) references citizen (id),
|
||||
foreign key (created_by_id) references citizen (id),
|
||||
foreign key (target_id) references citizen (id),
|
||||
primary key (id),
|
||||
unique (citizen_id, target_id)
|
||||
unique (created_by_id, target_id)
|
||||
) inherits (follow);
|
||||
|
||||
|
||||
@@ -231,9 +231,9 @@ create table comment
|
||||
(
|
||||
updated_at timestamptz default now() not null check ( updated_at >= created_at ),
|
||||
"content" text not null check ( content != '' and length(content) < 4096),
|
||||
parent_id uuid references comment (id),
|
||||
parent_id uuid references comment (id),
|
||||
parents_ids uuid[],
|
||||
foreign key (citizen_id) references citizen (id),
|
||||
foreign key (created_by_id) references citizen (id),
|
||||
primary key (id)
|
||||
) inherits (extra);
|
||||
|
||||
@@ -244,7 +244,7 @@ create or replace function set_comment_parents_ids() returns trigger
|
||||
language plpgsql as
|
||||
$$
|
||||
begin
|
||||
if(new.parent_id is not null) then
|
||||
if (new.parent_id is not null) then
|
||||
new.parents_ids = (
|
||||
select com.parents_ids || com.id
|
||||
from "comment" com
|
||||
@@ -267,7 +267,7 @@ execute procedure set_comment_parents_ids();
|
||||
create table comment_on_article
|
||||
(
|
||||
target_reference regclass default 'article'::regclass not null,
|
||||
foreign key (citizen_id) references citizen (id),
|
||||
foreign key (created_by_id) references citizen (id),
|
||||
foreign key (target_id) references article (id),
|
||||
foreign key (parent_id) references comment_on_article (id),
|
||||
primary key (id)
|
||||
@@ -285,7 +285,7 @@ execute procedure set_comment_parents_ids();
|
||||
create table comment_on_constitution
|
||||
(
|
||||
target_reference regclass default 'constitution'::regclass not null,
|
||||
foreign key (citizen_id) references citizen (id),
|
||||
foreign key (created_by_id) references citizen (id),
|
||||
foreign key (target_id) references constitution (id),
|
||||
foreign key (parent_id) references comment_on_constitution (id),
|
||||
primary key (id)
|
||||
@@ -306,45 +306,45 @@ create table vote
|
||||
(
|
||||
anonymous boolean default true not null,
|
||||
note int not null check ( note >= -1 and note <= 1 ),
|
||||
foreign key (citizen_id) references citizen (id),
|
||||
foreign key (created_by_id) references citizen (id),
|
||||
primary key (id),
|
||||
unique (citizen_id, target_id)
|
||||
unique (created_by_id, target_id)
|
||||
) inherits (extra);
|
||||
|
||||
create table vote_for_article
|
||||
(
|
||||
target_reference regclass default 'article'::regclass not null,
|
||||
foreign key (target_id) references article (id),
|
||||
foreign key (citizen_id) references citizen (id),
|
||||
foreign key (created_by_id) references citizen (id),
|
||||
primary key (id),
|
||||
unique (citizen_id, target_id)
|
||||
unique (created_by_id, target_id)
|
||||
) inherits (vote);
|
||||
|
||||
create table vote_for_constitution
|
||||
(
|
||||
target_reference regclass default 'constitution'::regclass not null,
|
||||
foreign key (target_id) references constitution (id),
|
||||
foreign key (citizen_id) references citizen (id),
|
||||
foreign key (created_by_id) references citizen (id),
|
||||
primary key (id),
|
||||
unique (citizen_id, target_id)
|
||||
unique (created_by_id, target_id)
|
||||
) inherits (vote);
|
||||
|
||||
create table vote_for_comment_on_article
|
||||
(
|
||||
target_reference regclass default 'comment_on_article'::regclass not null,
|
||||
foreign key (target_id) references comment_on_article (id),
|
||||
foreign key (citizen_id) references citizen (id),
|
||||
foreign key (created_by_id) references citizen (id),
|
||||
primary key (id),
|
||||
unique (citizen_id, target_id)
|
||||
unique (created_by_id, target_id)
|
||||
) inherits (vote);
|
||||
|
||||
create table vote_for_comment_on_constitution
|
||||
(
|
||||
target_reference regclass default 'comment_on_constitution'::regclass not null,
|
||||
foreign key (target_id) references comment_on_constitution (id),
|
||||
foreign key (citizen_id) references citizen (id),
|
||||
foreign key (created_by_id) references citizen (id),
|
||||
primary key (id),
|
||||
unique (citizen_id, target_id)
|
||||
unique (created_by_id, target_id)
|
||||
) inherits (vote);
|
||||
|
||||
-- Stats
|
||||
|
||||
Reference in New Issue
Block a user