Files
ubicloud/lib/sem_snap.rb
Burak Yucesoy 06b9eb8296 Use destroy instead of delete
In a subsequent commit, We will start to archive deleted records to a separate
table. Archiving will be done in before_destroy hook. Sequel does not trigger
any hooks for delete calls, so we are converting all delete calls to destroy.
Both calls are quite similar with few notable differences;
- delete does not trigger any hooks but destroy does.
- delete is more efficient while working with datasets, it directly runs DELETE
query with the given conditions of the dataset, but destroy instantiates each
object and calls destroy on the resulting object. For models, their performance
is comparable; only additional overhead comes from triggering hooks.
- Since destroy instantiates each object, it needs primary key. Thus we added
primary key to AppliedTag model.
- destroy does not work properly with returning as it processes each row one by
one.
2023-08-01 11:58:57 +03:00

1.1 KiB