mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Do not use delete_release stored procedure anymore to delete releases, FK's do it
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
2018-02-07 DariusIII
|
||||
* Chg: Do not use delete_release stored procedure anymore to delete releases, FK's do it
|
||||
* Chg: Remove yydecode setting check from yenc, will be dropped at later date
|
||||
2018-02-06 DariusIII
|
||||
* Chg: Update nunomaduro/collision to version 1.1.22
|
||||
|
||||
@@ -47,32 +47,7 @@ class AddStoredProcedures extends Migration
|
||||
END LOOP;
|
||||
CLOSE cur1;
|
||||
END;
|
||||
|
||||
|
||||
CREATE PROCEDURE delete_release(IN is_numeric BOOLEAN, IN identifier VARCHAR(40))
|
||||
COMMENT "Cascade deletes release from child tables when parent row is deleted"
|
||||
COMMENT "If is_numeric is true, identifier should be the releases_id, if false the guid"
|
||||
|
||||
main: BEGIN
|
||||
|
||||
DECLARE where_constr VARCHAR(255) DEFAULT "";
|
||||
|
||||
IF is_numeric IS TRUE
|
||||
THEN
|
||||
DELETE r
|
||||
FROM releases r
|
||||
WHERE r.id = identifier;
|
||||
|
||||
ELSEIF is_numeric IS FALSE
|
||||
THEN
|
||||
DELETE r
|
||||
FROM releases r
|
||||
WHERE r.guid = identifier;
|
||||
|
||||
ELSE LEAVE main;
|
||||
END IF;
|
||||
|
||||
END;');
|
||||
');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,6 +57,6 @@ CREATE PROCEDURE delete_release(IN is_numeric BOOLEAN, IN identifier VARCHAR(40)
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
DB::unprepared('DROP PROCEDURE loop_cbpm; DROP PROCEDURE delete_release;');
|
||||
DB::unprepared('DROP PROCEDURE loop_cbpm;');
|
||||
}
|
||||
}
|
||||
|
||||
+2
-9
@@ -543,7 +543,7 @@ class Releases
|
||||
* @param NZB $nzb
|
||||
* @param ReleaseImage $releaseImage
|
||||
*/
|
||||
public function deleteSingle($identifiers, $nzb, $releaseImage)
|
||||
public function deleteSingle($identifiers, $nzb, $releaseImage): void
|
||||
{
|
||||
// Delete NZB from disk.
|
||||
$nzbPath = $nzb->NZBPath($identifiers['g']);
|
||||
@@ -557,15 +557,8 @@ class Releases
|
||||
// Delete from sphinx.
|
||||
$this->sphinxSearch->deleteRelease($identifiers, $this->pdo);
|
||||
|
||||
$param1 = false;
|
||||
$param2 = $identifiers['g'];
|
||||
|
||||
// Delete from DB.
|
||||
$query = $this->pdo->Prepare('CALL delete_release(:is_numeric, :identifier)');
|
||||
$query->bindParam(':is_numeric', $param1, \PDO::PARAM_BOOL);
|
||||
$query->bindParam(':identifier', $param2);
|
||||
|
||||
$query->execute();
|
||||
Release::query()->where('guid', $identifiers['g'])->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user