-1

I need to delete some directories after rows relating to them are deleted. I have the folder names and they are very unique. If mysql isn't capable of doing this what are my other options (this is running on a linux server) and the folders contain numerous files.

answerSeeker
  • 2,692
  • 4
  • 38
  • 76
  • which language do you use to delete rows ? deleting files should be done from this same script. not mysql itself – Raphael PICCOLO Aug 24 '21 at 21:49
  • Run a bash script – BlackFox Aug 24 '21 at 21:49
  • @RaphaelPICCOLO I use php but the rows relating to the folders are deleted via a mysql temporal event – answerSeeker Aug 24 '21 at 21:49
  • 2
    If your trigger deletes the rows from your table and inserts the folder names into a "needs to be deleted" table, then you could write a crontab that runs a script every minute that reads the "needs to be deleted" table from the database, deletes the folders in there and then removes those rows from the "needs to be deleted" table. – Jerry Jeremiah Aug 24 '21 at 21:49

1 Answers1

3

this should be done from your code side (nodejs, php, etc) not on the sql side. the delete script should delete the related folders to prevent using esoteric/complex solutions.

But, it appears that you can, according to this thread : Invoking a PHP script from a MySQL trigger

Raphael PICCOLO
  • 2,095
  • 1
  • 12
  • 18
  • That's really interesting. I will look into this – answerSeeker Aug 24 '21 at 21:53
  • this particular thread is more specific to triggers : https://stackoverflow.com/questions/1467369/invoking-a-php-script-from-a-mysql-trigger – Raphael PICCOLO Aug 24 '21 at 21:56
  • What if the trigger runs the PHP script to delete a directory, and then the transaction that spawned the trigger rolls back? You don't get to roll back the deletion of the directory. – Bill Karwin Aug 25 '21 at 00:32