LukeBrandon / fluke

5 stars 0 forks source link

feat: cascade message deletes on channel delete #58

Closed LukeBrandon closed 10 months ago

LukeBrandon commented 10 months ago

Closes #52

Description of changes

Testing strategy

~/source/fluke/backend (master*) # curl -X POST -H "Content-Type: application/json" -d '{"name":"Test"}' http://localhost:8000/channels
{"id":2,"name":"Test","created_at":"2023-08-14T23:16:47.543928Z"}#                                                           -----------------------------------------------------------------------------------------------------------------------------
~/source/fluke/backend (master*) # curl -X POST -H "Content-Type: application/json" -d '{"message": "test messaage", "user_id": 1}' http://localhost:8000/channels/2/messages
{"id":2,"message":"test messaage","created_at":"2023-08-14T23:16:53.345451Z","user_id":1,"channel_id":2}#                    -----------------------------------------------------------------------------------------------------------------------------
~/source/fluke/backend (master*) # curl -X DELETE -H "Content-Type: application/json" http://localhost:8000/channels/2       {"error":"Database Error: error returned from database: update or delete on table \"channel\" violates foreign key constraint \"fk_message_channel_id\" on table \"message\""}#                                                                           -----------------------------------------------------------------------------------------------------------------------------
~/source/fluke/backend (master*) # sqlx migrate run                                                     root@DESKTOP-FD6S1B8
Applied 20230814230137/migrate message cascade delete (3.82432ms)
-----------------------------------------------------------------------------------------------------------------------------
~/source/fluke/backend (master*) # curl -X DELETE -H "Content-Type: application/json" http://localhost:8000/channels/2
{"channel":"Channel deleted"}#
FlynnOConnell commented 10 months ago

Great work, Luke!