   created timestamp not null default current_timestamp,
   modified timestamp not null default current_timestamp,
   user_id uuid not null references sg_public.user (id),  -- TODO allow anonymous
-  topic_id uuid not null references sg_public.topic (id),  
+  topic_id uuid not null references sg_public.topic (id),
   kind sg_public.post_kind not null default 'post',
-  body text null check (kind = 'vote' or body is not null),
+  body text null
+    check (kind = 'vote' or body is not null),
   replies_to_id uuid null references sg_public.post (id)
     check (kind <> 'vote' or replies_to_id is not null),
-  entity_versions jsonb null check (kind <> 'proposal' or entity_versions is not null),
+  entity_versions jsonb null
+    check (kind <> 'proposal' or entity_versions is not null),
     /* jsonb?: issue cant ref, cant enum composite TODO split into join table */
-  response boolean null check (kind <> 'vote' or response is not null)
+  response boolean null
+    check (kind <> 'vote' or response is not null)
 );
 -- todo comment table/columns
 


------ Cards, Units, Subjects > Triggers

create trigger update_unit_modified before update on sg_public.unit_version for each row execute procedure sg_private.update_modified_column(); -- TODO comment

create trigger update_subject_modified before update on sg_public.subject_version for each row execute procedure sg_private.update_modified_column();  -- TODO comment

create trigger update_card_modified before update on sg_public.card_version for each row execute procedure sg_private.update_modified_column();  -- TODO comment

create trigger update_card_parameters_modified before update on sg_public.card_parameters for each row execute procedure sg_private.update_modified_column();  -- TODO comment

------ Cards, Units, Subjects > Capabilities (TODO)


-- todo comment

create role sg_postgraphile login password 'xyz'; -- todo !!! fix password
create role sg_user;
create role sg_anonymous;
grant sg_user to sg_postgraphile;
grant sg_anonymous to sg_postgraphile;
-- todo comment on roles

---- Generic > Trigger Functions
