Added owner id to comment categories.

This commit is contained in:
flash 2020-05-30 14:46:32 +00:00
parent 1fdded1ad0
commit 2d97364f05
3 changed files with 48 additions and 5 deletions

View file

@ -0,0 +1,26 @@
<?php
namespace Misuzu\DatabaseMigrations\AddOwnerIdToComments;
use PDO;
function migrate_up(PDO $conn): void {
$conn->exec("
ALTER TABLE `msz_comments_categories`
ADD COLUMN `owner_id` INT UNSIGNED NULL DEFAULT NULL AFTER `category_name`,
ADD INDEX `comments_categories_owner_foreign` (`owner_id`),
ADD CONSTRAINT `comments_categories_owner_foreign`
FOREIGN KEY (`owner_id`)
REFERENCES `msz_users` (`user_id`)
ON UPDATE CASCADE
ON DELETE SET NULL;
");
}
function migrate_down(PDO $conn): void {
$conn->exec("
ALTER TABLE `msz_comments_categories`
DROP COLUMN `owner_id`,
DROP INDEX `comments_categories_owner_foreign`,
DROP FOREIGN KEY `comments_categories_owner_foreign`;
");
}