bounswe / bounswe2024group12

This repository contains Group 12's work for CMPE 352 - Spring 2024.
6 stars 1 forks source link

Clear the irrelevant data from deployment database #346

Open sonerkuyar opened 3 hours ago

sonerkuyar commented 3 hours ago

Description

There are some posts,comments and likes which are created during the trials of api by frontend, mobile and backend developers. These posts should be deleted to not show at customer milestone 2.


Acceptance Criteria

Reviewer:

This issue will be reviewed by: @isilsukarakuzuu

sonerkuyar commented 3 hours ago

I checked the posts and comments by looking at frontend app fetches from browser and deleted them from database via these kind of queries manually: mysql> delete from posts_post where id IN (35,36,37); mysql> delete from posts_comment where post_id IN (35,36,37);

Here are the all logs root@ubuntu-cmpe451:~/bounswe2024group12/app/backend# docker-compose exec db mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 28194 Server version: 8.0.39 MySQL Community Server - GPL Copyright (c) 2000, 2024, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use chess; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables; +--------------------------------------+ | Tables_in_chess | +--------------------------------------+ | accounts_customuser | | accounts_customuser_groups | | accounts_customuser_user_permissions | | auth_group | | auth_group_permissions | | auth_permission | | django_admin_log | | django_content_type | | django_migrations | | django_session | | games_game | | games_gamecomment | | posts_comment | | posts_like | | posts_post | +--------------------------------------+ 15 rows in set (0.00 sec) mysql> delete from posts_post -> where id between 0 and 10; ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`chess`.`posts_like`, CONSTRAINT `posts_like_post_id_127195b7_fk_posts_post_id` FOREIGN KEY (`post_id`) REFERENCES `posts_post` (`id`)) mysql> DELETE FROM posts_like WHERE post_id BETWEEN 0 AND 10 ; Query OK, 1 row affected (0.01 sec) mysql> delete from posts_post where id between 0 and 10; Query OK, 10 rows affected (0.00 sec) mysql> DELETE FROM posts_like WHERE post_id BETWEEN 18 AND 25 ; Query OK, 0 rows affected (0.00 sec) mysql> delete from posts_post where id between 18 and 25; Query OK, 8 rows affected (0.01 sec) mysql> delete from posts_post where id between 26 and 33; ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`chess`.`posts_comment`, CONSTRAINT `posts_comment_post_id_e81436d7_fk_posts_post_id` FOREIGN KEY (`post_id`) REFERENCES `posts_post` (`id`)) mysql> DELETE FROM posts_like WHERE post_id BETWEEN 26 AND 33 ; Query OK, 3 rows affected (0.01 sec) mysql> delete from posts_post where id between 26 and 33; ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`chess`.`posts_comment`, CONSTRAINT `posts_comment_post_id_e81436d7_fk_posts_post_id` FOREIGN KEY (`post_id`) REFERENCES `posts_post` (`id`)) mysql> DELETE FROM post_comment WHERE post_id BETWEEN 26 AND 33 ; ERROR 1146 (42S02): Table 'chess.post_comment' doesn't exist mysql> DELETE FROM posts_comment WHERE post_id BETWEEN 26 AND 33 ; Query OK, 9 rows affected (0.01 sec) mysql> delete from posts_post where id between 26 and 33; Query OK, 8 rows affected (0.01 sec) mysql> delete from posts_post where id between 45 and 48; ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`chess`.`posts_comment`, CONSTRAINT `posts_comment_post_id_e81436d7_fk_posts_post_id` FOREIGN KEY (`post_id`) REFERENCES `posts_post` (`id`)) mysql> delete from posts_commnet where id between 45 and 48; ERROR 1146 (42S02): Table 'chess.posts_commnet' doesn't exist mysql> delete from posts_comment where id between 45 and 48; Query OK, 0 rows affected (0.00 sec) mysql> delete from posts_post where id between 45 and 48; ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`chess`.`posts_comment`, CONSTRAINT `posts_comment_post_id_e81436d7_fk_posts_post_id` FOREIGN KEY (`post_id`) REFERENCES `posts_post` (`id`)) mysql> show tables; +--------------------------------------+ | Tables_in_chess | +--------------------------------------+ | accounts_customuser | | accounts_customuser_groups | | accounts_customuser_user_permissions | | auth_group | | auth_group_permissions | | auth_permission | | django_admin_log | | django_content_type | | django_migrations | | django_session | | games_game | | games_gamecomment | | posts_comment | | posts_like | | posts_post | +--------------------------------------+ 15 rows in set (0.00 sec) mysql> delete from posts_comment where post_id between 45 and 48; Query OK, 3 rows affected (0.00 sec) mysql> delete from posts_post where id between 45 and 48; ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`chess`.`posts_like`, CONSTRAINT `posts_like_post_id_127195b7_fk_posts_post_id` FOREIGN KEY (`post_id`) REFERENCES `posts_post` (`id`)) mysql> DELETE FROM posts_like WHERE post_id BETWEEN 45 AND 48 ; Query OK, 5 rows affected (0.00 sec) mysql> delete from posts_post where id between 45 and 48; Query OK, 4 rows affected (0.01 sec) mysql> delete from posts_post where id IN (35,36,37); ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`chess`.`posts_comment`, CONSTRAINT `posts_comment_post_id_e81436d7_fk_posts_post_id` FOREIGN KEY (`post_id`) REFERENCES `posts_post` (`id`)) mysql> delete from posts_comment where post_id IN (35,36,37); Query OK, 3 rows affected (0.00 sec) mysql> delete from posts_post where id IN (35,36,37); ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`chess`.`posts_like`, CONSTRAINT `posts_like_post_id_127195b7_fk_posts_post_id` FOREIGN KEY (`post_id`) REFERENCES `posts_post` (`id`)) mysql> delete from posts_like where post_id IN (35,36,37); Query OK, 1 row affected (0.00 sec) mysql> delete from posts_post where id IN (35,36,37); Query OK, 3 rows affected (0.01 sec) mysql>