on master help sign in
Resolved conflicts
commit2482476ea7ed34461c06574ee7c8649f62e751f0 authoriko <ilyakooo0@gmail.com> dateMon 4 Mar 2019, 00:35 (8 years ago) parent77d5dacda4afd7
3 files changed+16−7
denis/src/Data/Post.hs+1−1 denis/src/Data/Query.hs+7−6 denis/src/Data/Schema.hs+8
denis/src/Data/Post.hs+1−1
@@ -87,4 +87,4 @@ rowsToPost :: [PostRowResponse] -> Maybe Post
8787rowsToPost [] = Nothing
8888rowsToPost (el:els) = if all (((==) `on` postRowId) el) els
8989 then Post (postRowId el) (postRowAuthorId el) <$> traverse (unRow rowsToElement) (el:els)
90− else Nothing
90+ else Nothing
denis/src/Data/Query.hs+7−6
@@ -108,12 +108,13 @@ createPostRowQ = insertRow #posts
108108createPostElementRowsQ :: Manipulation Schema (TuplePG (PostElementRow Post)) '[]
109109createPostElementRowsQ = insertRow_ #postElements
110110 (Set (param @1) `as` #rowElementId :*
111− Set (param @2) `as` #rowElementOrd :*
112− Set (param @3) `as` #rowElementMarkdown :*
113− Set (param @4) `as` #rowElementLatex :*
114− Set (param @5) `as` #rowElementImage :*
115− Set (param @6) `as` #rowElementQuote :*
116− Set (param @7) `as` #rowElementAttachment)
111+ Set (param @2) `as` #rowElementAuthorId :*
112+ Set (param @3) `as` #rowElementOrd :*
113+ Set (param @4) `as` #rowElementMarkdown :*
114+ Set (param @5) `as` #rowElementLatex :*
115+ Set (param @6) `as` #rowElementImage :*
116+ Set (param @7) `as` #rowElementQuote :*
117+ Set (param @8) `as` #rowElementAttachment)
117118
118119-- MARK: FrontEnd functions
119120
denis/src/Data/Schema.hs+8
@@ -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 :*