A database update, for user deletion

now user_favorites clean itself too.
And a DBfix for those who installed shimmie before this date.
This commit is contained in:
NaGeL 2012-01-20 22:08:19 +01:00
parent 8eaaa6a7ca
commit b219d79a22
2 changed files with 13 additions and 1 deletions

10
DBupdate.php Normal file
View file

@ -0,0 +1,10 @@
<?php
require_once "core/compat.inc.php";
require_once "core/database.class.php";
include_once "config.php";
$db = new Database();
echo "Fixing user_favorites table....";
($db->Execute("ALTER TABLE user_favorites ENGINE=InnoDB;")) ? print_r("ok<br>") : print_r("failed<br>");
echo "adding Foreign key to users...";
($db->Execute("ALTER TABLE user_favorites ADD FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;"))? print_r("ok<br>"):print_r("failed<br>");
?>

View file

@ -144,8 +144,10 @@ class Favorites extends SimpleExtension {
image_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
created_at DATETIME NOT NULL,
INDEX(image_id),
UNIQUE(image_id, user_id),
INDEX(image_id)
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE
)
");
$config->set_int("ext_favorites_version", 1);