MySql Soft remove

I have an existing application (with MySQL DB).

I have a new requirement when I need to delete some records from one of the main objects. I do not want to use hard deletion here as my risky for the whole application. If I use soft delete, I have to add another is_deleted field, and because of this I need to update all my queries (for example, where is_deleted = '0').

Please let me know if there is a more reasonable way to handle this situation. I have to make changes to half the requests if I introduce a new flag to handle deletions.

0
source share
2 answers

- . MySQL ANSI-SPARC Architecture . 9 " " :

(, , ..) . , .

rename . :

my_data:

REMAME TABLE my_data TO my_data_flagged

ALTER TABLE my_data_flagged 
   ADD COLUMN is_deleted boolean NOT NULL default 0;

CREATE VIEW my_data AS 
   SELECT * 
   FROM my_data_flagged 
   WHERE  is_deleted = '0'

- .

+5

:

  • is_deleted dateTime, - deleted_Date... NULL, , , , , .

  • , , , , , , , .

  • , , , , , .

  • , , , .

+4

Source: https://habr.com/ru/post/1695189/


All Articles