on master help sign in
Resolved conflicts
2482476iko
denis/src/Data/Post.hs+1−1
@@ -87,4 +87,4 @@ rowsToPost :: [PostRowResponse] -> Maybe Post
87rowsToPost [] = Nothing
87rowsToPost [] = Nothing
88rowsToPost (el:els) = if all (((==) `on` postRowId) el) els
88rowsToPost (el:els) = if all (((==) `on` postRowId) el) els
89 then Post (postRowId el) (postRowAuthorId el) <$> traverse (unRow rowsToElement) (el:els)
89 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
108createPostElementRowsQ :: Manipulation Schema (TuplePG (PostElementRow Post)) '[]
108createPostElementRowsQ :: Manipulation Schema (TuplePG (PostElementRow Post)) '[]
109createPostElementRowsQ = insertRow_ #postElements
109createPostElementRowsQ = insertRow_ #postElements
110 (Set (param @1) `as` #rowElementId :*
110 (Set (param @1) `as` #rowElementId :*
111+ Set (param @2) `as` #rowElementAuthorId :*
111− Set (param @2) `as` #rowElementOrd :*
112+ Set (param @3) `as` #rowElementOrd :*
112− Set (param @3) `as` #rowElementMarkdown :*
113+ Set (param @4) `as` #rowElementMarkdown :*
113− Set (param @4) `as` #rowElementLatex :*
114+ Set (param @5) `as` #rowElementLatex :*
114− Set (param @5) `as` #rowElementImage :*
115+ Set (param @6) `as` #rowElementImage :*
115− Set (param @6) `as` #rowElementQuote :*
116+ Set (param @7) `as` #rowElementQuote :*
116− Set (param @7) `as` #rowElementAttachment)
117+ Set (param @8) `as` #rowElementAttachment)
117
118
118-- MARK: FrontEnd functions
119-- MARK: FrontEnd functions
119
120
denis/src/Data/Schema.hs+8
@@ -43,12 +43,14 @@ type Schema =
43 "postElements" ::: 'Table (
43 "postElements" ::: 'Table (
44 '[
44 '[
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"]
47 -- ,
48 -- ,
48 -- "unique_post_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
49 -- "unique_post_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
49 ] :=>
50 ] :=>
50 '[
51 '[
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 (
60 '[
62 '[
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"]
63 -- ,
66 -- ,
64 -- "unique_quote_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
67 -- "unique_quote_quote" ::: 'Check '["rowElementOrd", "rowElementMarkdown", "rowElementLatex", "rowElementImage", "rowElementQuote", "rowElementAttachment"]
65 ] :=>
68 ] :=>
66 '[
69 '[
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
118 ) (
123 ) (
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
129 ) (
136 ) (
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 :*