@@ -47,12 +47,14 @@ type Schema =
4747 "postElements" ::: 'Table (
4848 '[
4949 "fk_post_quote_self_id" ::: 'ForeignKey '["rowElementId"] "posts" '["postRowId"],
50+ "fk_post_element_user_id" ::: 'ForeignKey '["rowElementAuthorId"] "users" '["userId"],
5051 "fk_post_quote_id" ::: 'ForeignKey '["rowElementQuote"] "quotes" '["quoteRowId"]
5152 -- ,
5253 -- "unique_post_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
5354 ] :=>
5455 '[
5556 "rowElementId" ::: 'NoDef :=> 'NotNull 'PGint8,
57+ "rowElementAuthorId" ::: 'NoDef :=> 'NotNull 'PGint8,
5658 "rowElementOrd" ::: 'NoDef :=> 'NotNull 'PGint8,
5759 "rowElementMarkdown" ::: 'NoDef :=> 'Null 'PGtext,
5860 "rowElementLatex" ::: 'NoDef :=> 'Null 'PGtext,
@@ -63,12 +65,14 @@ type Schema =
6365 "quoteElements" ::: 'Table (
6466 '[
6567 "fk_quotes_quote_self_id" ::: 'ForeignKey '["rowElementId"] "quotes" '["quoteRowId"],
68+ "fk_quote_element_user_id" ::: 'ForeignKey '["rowElementAuthorId"] "users" '["userId"],
6669 "fk_quote_quote_id" ::: 'ForeignKey '["rowElementQuote"] "quotes" '["quoteRowId"]
6770 -- ,
6871 -- "unique_quote_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
6972 ] :=>
7073 '[
7174 "rowElementId" ::: 'NoDef :=> 'NotNull 'PGint8,
75+ "rowElementAuthorId" ::: 'NoDef :=> 'NotNull 'PGint8,
7276 "rowElementOrd" ::: 'NoDef :=> 'NotNull 'PGint8,
7377 "rowElementMarkdown" ::: 'NoDef :=> 'Null 'PGtext,
7478 "rowElementLatex" ::: 'NoDef :=> 'Null 'PGtext,
@@ -79,12 +83,14 @@ type Schema =
7983 "draftElements" ::: 'Table (
8084 '[
8185 "fk_draft_quote_self_id" ::: 'ForeignKey '["rowElementId"] "drafts" '["postRowId"],
86+ "fk_draft_element_user_id" ::: 'ForeignKey '["rowElementAuthorId"] "users" '["userId"],
8287 "fk_draft_quote_id" ::: 'ForeignKey '["rowElementQuote"] "quotes" '["quoteRowId"]
8388 -- ,
8489 -- "unique_post_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
8590 ] :=>
8691 '[
8792 "rowElementId" ::: 'NoDef :=> 'NotNull 'PGint8,
93+ "rowElementAuthorId" ::: 'NoDef :=> 'NotNull 'PGint8,
8894 "rowElementOrd" ::: 'NoDef :=> 'NotNull 'PGint8,
8995 "rowElementMarkdown" ::: 'NoDef :=> 'Null 'PGtext,
9096 "rowElementLatex" ::: 'NoDef :=> 'Null 'PGtext,
@@ -123,6 +129,7 @@ createTables = createTable #users (
123129 foreignKey #postRowAuthorId #users #userId OnDeleteCascade OnUpdateCascade `as` #fk_draft_author_id
124130 ) >>> createTable #postElements (
125131 notNullable int8 `as` #rowElementId :*
132+ notNullable int8 `as` #rowElementAuthorId :*
126133 notNullable int8 `as` #rowElementOrd :*
127134 nullable text `as` #rowElementMarkdown :*
128135 nullable text `as` #rowElementLatex :*
@@ -131,9 +138,11 @@ createTables = createTable #users (
131138 nullable text `as` #rowElementAttachment
132139 ) (
133140 foreignKey #rowElementId #posts #postRowId OnDeleteCascade OnUpdateCascade `as` #fk_post_quote_self_id :*
141+ foreignKey #rowElementAuthorId #users #userId OnDeleteCascade OnUpdateCascade `as` #fk_post_element_user_id :*
134142 foreignKey #rowElementQuote #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_post_quote_id
135143 ) >>> createTable #quoteElements (
136144 notNullable int8 `as` #rowElementId :*
145+ notNullable int8 `as` #rowElementAuthorId :*
137146 notNullable int8 `as` #rowElementOrd :*
138147 nullable text `as` #rowElementMarkdown :*
139148 nullable text `as` #rowElementLatex :*
@@ -142,9 +151,11 @@ createTables = createTable #users (
142151 nullable text `as` #rowElementAttachment
143152 ) (
144153 foreignKey #rowElementId #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_quotes_quote_self_id :*
154+ foreignKey #rowElementAuthorId #users #userId OnDeleteCascade OnUpdateCascade `as` #fk_quote_element_user_id :*
145155 foreignKey #rowElementQuote #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_quote_quote_id
146156 ) >>> createTable #draftElements (
147157 notNullable int8 `as` #rowElementId :*
158+ notNullable int8 `as` #rowElementAuthorId :*
148159 notNullable int8 `as` #rowElementOrd :*
149160 nullable text `as` #rowElementMarkdown :*
150161 nullable text `as` #rowElementLatex :*
@@ -153,6 +164,7 @@ createTables = createTable #users (
153164 nullable text `as` #rowElementAttachment
154165 ) (
155166 foreignKey #rowElementId #drafts #postRowId OnDeleteCascade OnUpdateCascade `as` #fk_draft_quote_self_id :*
167+ foreignKey #rowElementAuthorId #users #userId OnDeleteCascade OnUpdateCascade `as` #fk_draft_element_user_id :*
156168 foreignKey #rowElementQuote #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_draft_quote_id
157169 )
158170-- quoteUniquenessCheck :: TableConstraintExpression Schema _ (Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"])