@@ -43,12 +43,14 @@ type Schema =
43 "postElements" ::: 'Table (
43 "postElements" ::: 'Table (
45 "fk_post_quote_self_id" ::: 'ForeignKey '["rowElementId"] "posts" '["postRowId"],
45 "fk_post_quote_self_id" ::: 'ForeignKey '["rowElementId"] "posts" '["postRowId"],
46+ "fk_post_element_user_id" ::: 'ForeignKey '["rowElementAuthorId"] "users" '["userId"],
46 "fk_post_quote_id" ::: 'ForeignKey '["rowElementQuote"] "quotes" '["quoteRowId"]
47 "fk_post_quote_id" ::: 'ForeignKey '["rowElementQuote"] "quotes" '["quoteRowId"]
48 -- "unique_post_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
49 -- "unique_post_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
51 "rowElementId" ::: 'NoDef :=> 'NotNull 'PGint8,
52 "rowElementId" ::: 'NoDef :=> 'NotNull 'PGint8,
53+ "rowElementAuthorId" ::: 'NoDef :=> 'NotNull 'PGint8,
52 "rowElementOrd" ::: 'NoDef :=> 'NotNull 'PGint8,
54 "rowElementOrd" ::: 'NoDef :=> 'NotNull 'PGint8,
53 "rowElementMarkdown" ::: 'NoDef :=> 'Null 'PGtext,
55 "rowElementMarkdown" ::: 'NoDef :=> 'Null 'PGtext,
54 "rowElementLatex" ::: 'NoDef :=> 'Null 'PGtext,
56 "rowElementLatex" ::: 'NoDef :=> 'Null 'PGtext,
@@ -59,12 +61,14 @@ type Schema =
59 "quoteElements" ::: 'Table (
61 "quoteElements" ::: 'Table (
61 "fk_quotes_quote_self_id" ::: 'ForeignKey '["rowElementId"] "quotes" '["quoteRowId"],
63 "fk_quotes_quote_self_id" ::: 'ForeignKey '["rowElementId"] "quotes" '["quoteRowId"],
64+ "fk_quote_element_user_id" ::: 'ForeignKey '["rowElementAuthorId"] "users" '["userId"],
62 "fk_quote_quote_id" ::: 'ForeignKey '["rowElementQuote"] "quotes" '["quoteRowId"]
65 "fk_quote_quote_id" ::: 'ForeignKey '["rowElementQuote"] "quotes" '["quoteRowId"]
64 -- "unique_quote_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
67 -- "unique_quote_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
67 "rowElementId" ::: 'NoDef :=> 'NotNull 'PGint8,
70 "rowElementId" ::: 'NoDef :=> 'NotNull 'PGint8,
71+ "rowElementAuthorId" ::: 'NoDef :=> 'NotNull 'PGint8,
68 "rowElementOrd" ::: 'NoDef :=> 'NotNull 'PGint8,
72 "rowElementOrd" ::: 'NoDef :=> 'NotNull 'PGint8,
69 "rowElementMarkdown" ::: 'NoDef :=> 'Null 'PGtext,
73 "rowElementMarkdown" ::: 'NoDef :=> 'Null 'PGtext,
70 "rowElementLatex" ::: 'NoDef :=> 'Null 'PGtext,
74 "rowElementLatex" ::: 'NoDef :=> 'Null 'PGtext,
@@ -109,6 +113,7 @@ createTables = createTable #users (
109 foreignKey #quoteRowPostId #posts #postRowId OnDeleteCascade OnUpdateCascade `as` #fk_quote_post_id
113 foreignKey #quoteRowPostId #posts #postRowId OnDeleteCascade OnUpdateCascade `as` #fk_quote_post_id
110 ) >>> createTable #postElements (
114 ) >>> createTable #postElements (
111 notNullable int8 `as` #rowElementId :*
115 notNullable int8 `as` #rowElementId :*
116+ notNullable int8 `as` #rowElementAuthorId :*
112 notNullable int8 `as` #rowElementOrd :*
117 notNullable int8 `as` #rowElementOrd :*
113 nullable text `as` #rowElementMarkdown :*
118 nullable text `as` #rowElementMarkdown :*
114 nullable text `as` #rowElementLatex :*
119 nullable text `as` #rowElementLatex :*
@@ -117,9 +122,11 @@ createTables = createTable #users (
117 nullable text `as` #rowElementAttachment
122 nullable text `as` #rowElementAttachment
119 foreignKey #rowElementId #posts #postRowId OnDeleteCascade OnUpdateCascade `as` #fk_post_quote_self_id :*
124 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 :*
120 foreignKey #rowElementQuote #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_post_quote_id
126 foreignKey #rowElementQuote #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_post_quote_id
121 ) >>> createTable #quoteElements (
127 ) >>> createTable #quoteElements (
122 notNullable int8 `as` #rowElementId :*
128 notNullable int8 `as` #rowElementId :*
129+ notNullable int8 `as` #rowElementAuthorId :*
123 notNullable int8 `as` #rowElementOrd :*
130 notNullable int8 `as` #rowElementOrd :*
124 nullable text `as` #rowElementMarkdown :*
131 nullable text `as` #rowElementMarkdown :*
125 nullable text `as` #rowElementLatex :*
132 nullable text `as` #rowElementLatex :*
@@ -128,6 +135,7 @@ createTables = createTable #users (
128 nullable text `as` #rowElementAttachment
135 nullable text `as` #rowElementAttachment
130 foreignKey #rowElementId #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_quotes_quote_self_id :*
137 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 :*
131 foreignKey #rowElementQuote #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_quote_quote_id
139 foreignKey #rowElementQuote #quotes #quoteRowId OnDeleteCascade OnUpdateCascade `as` #fk_quote_quote_id
132 -- ) >>> createView #postsView (select (
140 -- ) >>> createView #postsView (select (
133 -- #posts ! #postRowId :*
141 -- #posts ! #postRowId :*