@@ -47,12 +47,14 @@ type Schema =
47 "postElements" ::: 'Table (
47 "postElements" ::: 'Table (
49 "fk_post_quote_self_id" ::: 'ForeignKey '["rowElementId"] "posts" '["postRowId"],
49 "fk_post_quote_self_id" ::: 'ForeignKey '["rowElementId"] "posts" '["postRowId"],
50+ "fk_post_element_user_id" ::: 'ForeignKey '["rowElementAuthorId"] "users" '["userId"],
50 "fk_post_quote_id" ::: 'ForeignKey '["rowElementQuote"] "quotes" '["quoteRowId"]
51 "fk_post_quote_id" ::: 'ForeignKey '["rowElementQuote"] "quotes" '["quoteRowId"]
52 -- "unique_post_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
53 -- "unique_post_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
55 "rowElementId" ::: 'NoDef :=> 'NotNull 'PGint8,
56 "rowElementId" ::: 'NoDef :=> 'NotNull 'PGint8,
57+ "rowElementAuthorId" ::: 'NoDef :=> 'NotNull 'PGint8,
56 "rowElementOrd" ::: 'NoDef :=> 'NotNull 'PGint8,
58 "rowElementOrd" ::: 'NoDef :=> 'NotNull 'PGint8,
57 "rowElementMarkdown" ::: 'NoDef :=> 'Null 'PGtext,
59 "rowElementMarkdown" ::: 'NoDef :=> 'Null 'PGtext,
58 "rowElementLatex" ::: 'NoDef :=> 'Null 'PGtext,
60 "rowElementLatex" ::: 'NoDef :=> 'Null 'PGtext,
@@ -63,12 +65,14 @@ type Schema =
63 "quoteElements" ::: 'Table (
65 "quoteElements" ::: 'Table (
65 "fk_quotes_quote_self_id" ::: 'ForeignKey '["rowElementId"] "quotes" '["quoteRowId"],
67 "fk_quotes_quote_self_id" ::: 'ForeignKey '["rowElementId"] "quotes" '["quoteRowId"],
68+ "fk_quote_element_user_id" ::: 'ForeignKey '["rowElementAuthorId"] "users" '["userId"],
66 "fk_quote_quote_id" ::: 'ForeignKey '["rowElementQuote"] "quotes" '["quoteRowId"]
69 "fk_quote_quote_id" ::: 'ForeignKey '["rowElementQuote"] "quotes" '["quoteRowId"]
68 -- "unique_quote_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
71 -- "unique_quote_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
71 "rowElementId" ::: 'NoDef :=> 'NotNull 'PGint8,
74 "rowElementId" ::: 'NoDef :=> 'NotNull 'PGint8,
75+ "rowElementAuthorId" ::: 'NoDef :=> 'NotNull 'PGint8,
72 "rowElementOrd" ::: 'NoDef :=> 'NotNull 'PGint8,
76 "rowElementOrd" ::: 'NoDef :=> 'NotNull 'PGint8,
73 "rowElementMarkdown" ::: 'NoDef :=> 'Null 'PGtext,
77 "rowElementMarkdown" ::: 'NoDef :=> 'Null 'PGtext,
74 "rowElementLatex" ::: 'NoDef :=> 'Null 'PGtext,
78 "rowElementLatex" ::: 'NoDef :=> 'Null 'PGtext,
@@ -79,12 +83,14 @@ type Schema =
79 "draftElements" ::: 'Table (
83 "draftElements" ::: 'Table (
81 "fk_draft_quote_self_id" ::: 'ForeignKey '["rowElementId"] "drafts" '["postRowId"],
85 "fk_draft_quote_self_id" ::: 'ForeignKey '["rowElementId"] "drafts" '["postRowId"],
86+ "fk_draft_element_user_id" ::: 'ForeignKey '["rowElementAuthorId"] "users" '["userId"],
82 "fk_draft_quote_id" ::: 'ForeignKey '["rowElementQuote"] "quotes" '["quoteRowId"]
87 "fk_draft_quote_id" ::: 'ForeignKey '["rowElementQuote"] "quotes" '["quoteRowId"]
84 -- "unique_post_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
89 -- "unique_post_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
87 "rowElementId" ::: 'NoDef :=> 'NotNull 'PGint8,
92 "rowElementId" ::: 'NoDef :=> 'NotNull 'PGint8,
93+ "rowElementAuthorId" ::: 'NoDef :=> 'NotNull 'PGint8,
88 "rowElementOrd" ::: 'NoDef :=> 'NotNull 'PGint8,
94 "rowElementOrd" ::: 'NoDef :=> 'NotNull 'PGint8,
89 "rowElementMarkdown" ::: 'NoDef :=> 'Null 'PGtext,
95 "rowElementMarkdown" ::: 'NoDef :=> 'Null 'PGtext,
90 "rowElementLatex" ::: 'NoDef :=> 'Null 'PGtext,
96 "rowElementLatex" ::: 'NoDef :=> 'Null 'PGtext,
@@ -123,6 +129,7 @@ createTables = createTable #users (
123 foreignKey #postRowAuthorId #users #userId OnDeleteCascade OnUpdateCascade `as` #fk_draft_author_id
129 foreignKey #postRowAuthorId #users #userId OnDeleteCascade OnUpdateCascade `as` #fk_draft_author_id
124 ) >>> createTable #postElements (
130 ) >>> createTable #postElements (
125 notNullable int8 `as` #rowElementId :*
131 notNullable int8 `as` #rowElementId :*
132+ notNullable int8 `as` #rowElementAuthorId :*
126 notNullable int8 `as` #rowElementOrd :*
133 notNullable int8 `as` #rowElementOrd :*
127 nullable text `as` #rowElementMarkdown :*
134 nullable text `as` #rowElementMarkdown :*
128 nullable text `as` #rowElementLatex :*
135 nullable text `as` #rowElementLatex :*
@@ -131,9 +138,11 @@ createTables = createTable #users (
131 nullable text `as` #rowElementAttachment
138 nullable text `as` #rowElementAttachment
133 foreignKey #rowElementId #posts #postRowId OnDeleteCascade OnUpdateCascade `as` #fk_post_quote_self_id :*
140 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 :*
134 foreignKey #rowElementQuote #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_post_quote_id
142 foreignKey #rowElementQuote #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_post_quote_id
135 ) >>> createTable #quoteElements (
143 ) >>> createTable #quoteElements (
136 notNullable int8 `as` #rowElementId :*
144 notNullable int8 `as` #rowElementId :*
145+ notNullable int8 `as` #rowElementAuthorId :*
137 notNullable int8 `as` #rowElementOrd :*
146 notNullable int8 `as` #rowElementOrd :*
138 nullable text `as` #rowElementMarkdown :*
147 nullable text `as` #rowElementMarkdown :*
139 nullable text `as` #rowElementLatex :*
148 nullable text `as` #rowElementLatex :*
@@ -142,9 +151,11 @@ createTables = createTable #users (
142 nullable text `as` #rowElementAttachment
151 nullable text `as` #rowElementAttachment
144 foreignKey #rowElementId #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_quotes_quote_self_id :*
153 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 :*
145 foreignKey #rowElementQuote #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_quote_quote_id
155 foreignKey #rowElementQuote #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_quote_quote_id
146 ) >>> createTable #draftElements (
156 ) >>> createTable #draftElements (
147 notNullable int8 `as` #rowElementId :*
157 notNullable int8 `as` #rowElementId :*
158+ notNullable int8 `as` #rowElementAuthorId :*
148 notNullable int8 `as` #rowElementOrd :*
159 notNullable int8 `as` #rowElementOrd :*
149 nullable text `as` #rowElementMarkdown :*
160 nullable text `as` #rowElementMarkdown :*
150 nullable text `as` #rowElementLatex :*
161 nullable text `as` #rowElementLatex :*
@@ -153,6 +164,7 @@ createTables = createTable #users (
153 nullable text `as` #rowElementAttachment
164 nullable text `as` #rowElementAttachment
155 foreignKey #rowElementId #drafts #postRowId OnDeleteCascade OnUpdateCascade `as` #fk_draft_quote_self_id :*
166 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 :*
156 foreignKey #rowElementQuote #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_draft_quote_id
168 foreignKey #rowElementQuote #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_draft_quote_id
158-- quoteUniquenessCheck :: TableConstraintExpression Schema _ (Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"])
170-- quoteUniquenessCheck :: TableConstraintExpression Schema _ (Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"])