Okay, I've just inherited a project from a previous developer, before I came in they had problems of a particular table losing records and leaving exactly the same number of records each time, the records get erased completely. And I noticed that there are lots of DELETE
statements in the code as well, but I can't find the script that deletes the records.
For now I run a CRON job twice a day to back up the database.
I have checked for CASCADE DELETE using this SQL
USE information_schema;
SELECT
table_name
FROM
referential_constraints
WHERE
constraint_schema = 'my_database_name'
AND referenced_table_name IN
(SELECT table_name
FROM information_schema.tables
WHERE table_schema ='my_database_name')
AND delete_rule = 'CASCADE'
It lists all the tables in my database and checks for any possibilities of a CASCADE DELETE, but so far it returns empty.
I use SQL
a lot because I'm a back-end developer but I'm not an expert at it. So I could really use some help because it's getting quite embarrassing each time it happens. It's a MySQL
database. Thanks.