Postgres: Drop Post/Comment-based tables after populating Message-based ones
@@ -33,13 +33,26 @@ INSERT INTO Message
;
INSERT INTO Person_likes_Message
- SELECT creationDate, PersonId, CommentId AS id FROM Person_likes_Comment
- UNION ALL
SELECT creationDate, PersonId, PostId AS id FROM Person_likes_Post
;
+INSERT INTO Person_likes_Message
+ SELECT creationDate, PersonId, CommentId AS id FROM Person_likes_Comment
+;
+
INSERT INTO Message_hasTag_Tag
- SELECT creationDate, CommentId AS id, TagId FROM Comment_hasTag_Tag
- UNION ALL
SELECT creationDate, PostId AS id, TagId FROM Post_hasTag_Tag
;
+
+INSERT INTO Message_hasTag_Tag
+ SELECT creationDate, CommentId AS id, TagId FROM Comment_hasTag_Tag
+;
+
+DROP TABLE IF EXISTS Post;
+DROP TABLE IF EXISTS Comment;
+
+DROP TABLE IF EXISTS Person_likes_Post;
+DROP TABLE IF EXISTS Person_likes_Comment;
+
+DROP TABLE IF EXISTS Post_hasTag_Tag;
+DROP TABLE IF EXISTS Comment_hasTag_Tag;
