@@ -43,12 +43,14 @@ type Schema =
4343 "postElements" ::: 'Table (
4444 '[
4545 "fk_post_quote_self_id" ::: 'ForeignKey '["rowElementId"] "posts" '["postRowId"],
46+ "fk_post_element_user_id" ::: 'ForeignKey '["rowElementAuthorId"] "users" '["userId"],
4647 "fk_post_quote_id" ::: 'ForeignKey '["rowElementQuote"] "quotes" '["quoteRowId"]
4748 -- ,
4849 -- "unique_post_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
4950 ] :=>
5051 '[
5152 "rowElementId" ::: 'NoDef :=> 'NotNull 'PGint8,
53+ "rowElementAuthorId" ::: 'NoDef :=> 'NotNull 'PGint8,
5254 "rowElementOrd" ::: 'NoDef :=> 'NotNull 'PGint8,
5355 "rowElementMarkdown" ::: 'NoDef :=> 'Null 'PGtext,
5456 "rowElementLatex" ::: 'NoDef :=> 'Null 'PGtext,
@@ -59,12 +61,14 @@ type Schema =
5961 "quoteElements" ::: 'Table (
6062 '[
6163 "fk_quotes_quote_self_id" ::: 'ForeignKey '["rowElementId"] "quotes" '["quoteRowId"],
64+ "fk_quote_element_user_id" ::: 'ForeignKey '["rowElementAuthorId"] "users" '["userId"],
6265 "fk_quote_quote_id" ::: 'ForeignKey '["rowElementQuote"] "quotes" '["quoteRowId"]
6366 -- ,
6467 -- "unique_quote_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
6568 ] :=>
6669 '[
6770 "rowElementId" ::: 'NoDef :=> 'NotNull 'PGint8,
71+ "rowElementAuthorId" ::: 'NoDef :=> 'NotNull 'PGint8,
6872 "rowElementOrd" ::: 'NoDef :=> 'NotNull 'PGint8,
6973 "rowElementMarkdown" ::: 'NoDef :=> 'Null 'PGtext,
7074 "rowElementLatex" ::: 'NoDef :=> 'Null 'PGtext,
@@ -109,6 +113,7 @@ createTables = createTable #users (
109113 foreignKey #quoteRowPostId #posts #postRowId OnDeleteCascade OnUpdateCascade `as` #fk_quote_post_id
110114 ) >>> createTable #postElements (
111115 notNullable int8 `as` #rowElementId :*
116+ notNullable int8 `as` #rowElementAuthorId :*
112117 notNullable int8 `as` #rowElementOrd :*
113118 nullable text `as` #rowElementMarkdown :*
114119 nullable text `as` #rowElementLatex :*
@@ -117,9 +122,11 @@ createTables = createTable #users (
117122 nullable text `as` #rowElementAttachment
118123 ) (
119124 foreignKey #rowElementId #posts #postRowId OnDeleteCascade OnUpdateCascade `as` #fk_post_quote_self_id :*
125+ foreignKey #rowElementAuthorId #users #userId OnDeleteCascade OnUpdateCascade `as` #fk_post_element_user_id :*
120126 foreignKey #rowElementQuote #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_post_quote_id
121127 ) >>> createTable #quoteElements (
122128 notNullable int8 `as` #rowElementId :*
129+ notNullable int8 `as` #rowElementAuthorId :*
123130 notNullable int8 `as` #rowElementOrd :*
124131 nullable text `as` #rowElementMarkdown :*
125132 nullable text `as` #rowElementLatex :*
@@ -128,6 +135,7 @@ createTables = createTable #users (
128135 nullable text `as` #rowElementAttachment
129136 ) (
130137 foreignKey #rowElementId #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_quotes_quote_self_id :*
138+ foreignKey #rowElementAuthorId #users #userId OnDeleteCascade OnUpdateCascade `as` #fk_quote_element_user_id :*
131139 foreignKey #rowElementQuote #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_quote_quote_id
132140 -- ) >>> createView #postsView (select (
133141 -- #posts ! #postRowId :*