Removed support for rolling back database migrations.

This commit is contained in:
flash 2023-01-01 03:42:18 +00:00
parent 8245bc0a7b
commit ca814279f1
20 changed files with 12 additions and 329 deletions

View file

@ -671,34 +671,3 @@ function migrate_up(PDO $conn): void {
) COLLATE='utf8mb4_bin' ENGINE=InnoDB;
");
}
function migrate_down(PDO $conn): void {
$conn->exec("DROP TABLE `msz_forum_posts`");
$conn->exec("DROP TABLE `msz_forum_topics_track`");
$conn->exec("DROP TABLE `msz_forum_topics`");
$conn->exec("DROP TABLE `msz_forum_permissions`");
$conn->exec("DROP TABLE `msz_forum_categories`");
$conn->exec("DROP TABLE `msz_forum_polls_answers`");
$conn->exec("DROP TABLE `msz_forum_polls_options`");
$conn->exec("DROP TABLE `msz_forum_polls`");
$conn->exec("DROP TABLE `msz_changelog_change_tags`");
$conn->exec("DROP TABLE `msz_changelog_changes`");
$conn->exec("DROP TABLE `msz_changelog_tags`");
$conn->exec("DROP TABLE `msz_news_posts`");
$conn->exec("DROP TABLE `msz_news_categories`");
$conn->exec("DROP TABLE `msz_comments_votes`");
$conn->exec("DROP TABLE `msz_comments_posts`");
$conn->exec("DROP TABLE `msz_comments_categories`");
$conn->exec("DROP TABLE `msz_login_attempts`");
$conn->exec("DROP TABLE `msz_auth_tfa`");
$conn->exec("DROP TABLE `msz_audit_log`");
$conn->exec("DROP TABLE `msz_permissions`");
$conn->exec("DROP TABLE `msz_sessions`");
$conn->exec("DROP TABLE `msz_user_warnings`");
$conn->exec("DROP TABLE `msz_user_relations`");
$conn->exec("DROP TABLE `msz_users_password_resets`");
$conn->exec("DROP TABLE `msz_user_roles`");
$conn->exec("DROP TABLE `msz_users`");
$conn->exec("DROP TABLE `msz_roles`");
$conn->exec("DROP TABLE `msz_ip_blacklist`");
}

View file

@ -9,10 +9,3 @@ function migrate_up(PDO $conn): void {
ADD COLUMN `forum_icon` VARCHAR(50) NULL DEFAULT NULL AFTER `forum_description`;
");
}
function migrate_down(PDO $conn): void {
$conn->exec("
ALTER TABLE `msz_forum_categories`
DROP COLUMN `forum_icon`;
");
}

View file

@ -25,9 +25,3 @@ function migrate_up(PDO $conn): void {
) COLLATE='utf8mb4_bin' ENGINE=InnoDB;
");
}
function migrate_down(PDO $conn): void {
$conn->exec("
DROP TABLE `msz_forum_topics_priority`
");
}

View file

@ -19,9 +19,3 @@ function migrate_up(PDO $conn): void {
) COLLATE='utf8mb4_bin' ENGINE=InnoDB;
");
}
function migrate_down(PDO $conn): void {
$conn->exec("
DROP TABLE `msz_emoticons`;
");
}

View file

@ -12,7 +12,3 @@ function migrate_up(PDO $conn): void {
) COLLATE='utf8mb4_bin' ENGINE=InnoDB;
");
}
function migrate_down(PDO $conn): void {
$conn->exec("DROP TABLE `msz_config`;");
}

View file

@ -159,39 +159,3 @@ function migrate_up(PDO $conn): void {
DROP COLUMN `user_lastfm`;
");
}
function migrate_down(PDO $conn): void {
$conn->exec("
ALTER TABLE `msz_users`
ADD COLUMN `user_website` VARCHAR(255) NOT NULL DEFAULT '' COLLATE 'utf8mb4_bin' AFTER `user_background_settings`,
ADD COLUMN `user_twitter` VARCHAR(20) NOT NULL DEFAULT '' COLLATE 'utf8mb4_bin' AFTER `user_website`,
ADD COLUMN `user_github` VARCHAR(40) NOT NULL DEFAULT '' COLLATE 'utf8mb4_bin' AFTER `user_twitter`,
ADD COLUMN `user_skype` VARCHAR(60) NOT NULL DEFAULT '' COLLATE 'utf8mb4_bin' AFTER `user_github`,
ADD COLUMN `user_discord` VARCHAR(40) NOT NULL DEFAULT '' COLLATE 'utf8mb4_bin' AFTER `user_skype`,
ADD COLUMN `user_youtube` VARCHAR(255) NOT NULL DEFAULT '' COLLATE 'utf8mb4_bin' AFTER `user_discord`,
ADD COLUMN `user_steam` VARCHAR(255) NOT NULL DEFAULT '' COLLATE 'utf8mb4_bin' AFTER `user_youtube`,
ADD COLUMN `user_ninswitch` VARCHAR(14) NOT NULL DEFAULT '' COLLATE 'utf8mb4_bin' AFTER `user_steam`,
ADD COLUMN `user_twitchtv` VARCHAR(30) NOT NULL DEFAULT '' COLLATE 'utf8mb4_bin' AFTER `user_ninswitch`,
ADD COLUMN `user_osu` VARCHAR(20) NOT NULL DEFAULT '' COLLATE 'utf8mb4_bin' AFTER `user_twitchtv`,
ADD COLUMN `user_lastfm` VARCHAR(20) NOT NULL DEFAULT '' COLLATE 'utf8mb4_bin' AFTER `user_osu`;
");
$existingFields = $conn->query("
SELECT pfv.`user_id`, pf.`field_key`, pfv.`field_value`
FROM `msz_profile_fields_values` AS pfv
LEFT JOIN `msz_profile_fields` AS pf
ON pf.`field_id` = pfv.`field_id`
");
$updatePreps = [];
foreach($existingFields as $field) {
($updatePreps[$field['field_key']] ?? ($updatePreps[$field['field_key']] = $conn->prepare("UPDATE `msz_users` SET `user_{$field['field_key']}` = :value WHERE `user_id` = :user_id")))->execute([
'value' => $field['field_value'],
'user_id' => $field['user_id'],
]);
}
$conn->exec("DROP TABLE `msz_profile_fields_values`");
$conn->exec("DROP TABLE `msz_profile_fields_formats`");
$conn->exec("DROP TABLE `msz_profile_fields`");
}

View file

@ -73,14 +73,3 @@ function migrate_up(PDO $conn): void {
}
}
}
function migrate_down(PDO $conn): void {
$conn->exec('DROP TABLE `msz_emoticons_strings`');
$conn->exec("
ALTER TABLE `msz_emoticons`
ADD COLUMN `emote_string` VARCHAR(50) NOT NULL COLLATE 'ascii_general_nopad_ci' AFTER `emote_hierarchy`,
DROP INDEX `emotes_url`,
ADD INDEX `emotes_url` (`emote_url`),
ADD UNIQUE INDEX `emote_string` (`emote_url`);
");
}

View file

@ -20,7 +20,3 @@ function migrate_up(PDO $conn): void {
) COLLATE='utf8mb4_bin' ENGINE=InnoDB;
");
}
function migrate_down(PDO $conn): void {
$conn->exec("DROP TABLE `msz_user_chat_tokens`");
}

View file

@ -10,12 +10,3 @@ function migrate_up(PDO $conn): void {
ADD INDEX `audit_log_created_index` (`log_created`);
');
}
function migrate_down(PDO $conn): void {
$conn->exec("
ALTER TABLE `msz_audit_log`
ADD COLUMN `log_id` INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST,
DROP INDEX `audit_log_created_index`,
ADD PRIMARY KEY (`log_id`);
");
}

View file

@ -10,12 +10,3 @@ function migrate_up(PDO $conn): void {
ADD INDEX `login_attempts_created_index` (`attempt_created`);
");
}
function migrate_down(PDO $conn): void {
$conn->exec("
ALTER TABLE `msz_login_attempts`
ADD COLUMN `attempt_id` INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST,
DROP INDEX `login_attempts_created_index`,
ADD PRIMARY KEY (`attempt_id`);
");
}

View file

@ -11,12 +11,3 @@ function migrate_up(PDO $conn): void {
ADD INDEX `sessions_created_index` (`session_created`);
");
}
function migrate_down(PDO $conn): void {
$conn->exec("
ALTER TABLE `msz_sessions`
CHANGE COLUMN `session_key` `session_key` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_bin' AFTER `user_id`,
CHANGE COLUMN `session_expires` `session_expires` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP() AFTER `session_country`,
DROP INDEX `sessions_created_index`;
");
}

View file

@ -33,34 +33,3 @@ function migrate_up(PDO $conn): void {
ADD INDEX `user_relations_created_index` (`relation_created`);
");
}
function migrate_down(PDO $conn): void {
$conn->exec("
ALTER TABLE `msz_forum_categories`
DROP INDEX `forum_link_clicks_index`,
DROP INDEX `forum_hidden_index`;
");
$conn->exec("
ALTER TABLE `msz_login_attempts`
DROP INDEX `login_attempts_success_index`,
DROP INDEX `login_attempts_ip_index`;
");
$conn->exec("
ALTER TABLE `msz_news_categories`
DROP INDEX `news_categories_is_hidden_index`;
");
$conn->exec("
ALTER TABLE `msz_roles`
DROP INDEX `roles_hierarchy_index`,
DROP INDEX `roles_hidden_index`;
");
$conn->exec("
ALTER TABLE `msz_user_relations`
DROP INDEX `user_relations_type_index`,
DROP INDEX `user_relations_created_index`;
");
}

View file

@ -14,15 +14,3 @@ function migrate_up(PDO $conn): void {
ADD UNIQUE INDEX `users_password_resets_token_unique` (`verification_code`);
");
}
function migrate_down(PDO $conn): void {
$conn->exec("
ALTER TABLE `msz_users_password_resets`
CHANGE COLUMN `verification_code` `verification_code` CHAR(12) NULL DEFAULT NULL COLLATE 'utf8mb4_bin' AFTER `reset_requested`,
DROP INDEX `users_password_resets_user_unique`,
ADD UNIQUE INDEX `msz_users_password_resets_unique` (`user_id`, `reset_ip`),
DROP INDEX `users_password_resets_created_index`,
ADD INDEX `msz_users_password_resets_index` (`reset_requested`),
DROP INDEX `users_password_resets_token_unique`;
");
}

View file

@ -14,15 +14,3 @@ function migrate_up(PDO $conn): void {
CHANGE COLUMN `post_text` `post_text` TEXT(65535) NOT NULL COLLATE 'utf8mb4_unicode_ci' AFTER `post_ip`;
");
}
function migrate_down(PDO $conn): void {
$conn->exec("
ALTER TABLE `msz_forum_topics`
CHANGE COLUMN `topic_title` `topic_title` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_bin' AFTER `topic_type`;
");
$conn->exec("
ALTER TABLE `msz_forum_posts`
CHANGE COLUMN `post_text` `post_text` TEXT(65535) NOT NULL COLLATE 'utf8mb4_bin' AFTER `post_ip`;
");
}

View file

@ -15,12 +15,3 @@ function migrate_up(PDO $conn): void {
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`;
");
}

View file

@ -6,28 +6,3 @@ use PDO;
function migrate_up(PDO $conn): void {
$conn->exec("DROP TABLE `msz_user_relations`");
}
function migrate_down(PDO $conn): void {
$conn->exec("
CREATE TABLE `msz_user_relations` (
`user_id` INT(10) UNSIGNED NOT NULL,
`subject_id` INT(10) UNSIGNED NOT NULL,
`relation_type` TINYINT(3) UNSIGNED NOT NULL,
`relation_created` TIMESTAMP NOT NULL DEFAULT current_timestamp(),
UNIQUE INDEX `user_relations_unique` (`user_id`, `subject_id`) USING BTREE,
INDEX `user_relations_subject_id_foreign` (`subject_id`) USING BTREE,
INDEX `user_relations_type_index` (`relation_type`) USING BTREE,
INDEX `user_relations_created_index` (`relation_created`) USING BTREE,
CONSTRAINT `user_relations_subject_id_foreign`
FOREIGN KEY (`subject_id`)
REFERENCES `msz_users` (`user_id`)
ON UPDATE CASCADE
ON DELETE CASCADE,
CONSTRAINT `user_relations_user_id_foreign`
FOREIGN KEY (`user_id`)
REFERENCES `msz_users` (`user_id`)
ON UPDATE CASCADE
ON DELETE CASCADE
) COLLATE='utf8mb4_bin' ENGINE=InnoDB;
");
}

View file

@ -6,21 +6,3 @@ use PDO;
function migrate_up(PDO $conn): void {
$conn->exec("DROP TABLE `msz_user_chat_tokens`");
}
function migrate_down(PDO $conn): void {
$conn->exec("
CREATE TABLE `msz_user_chat_tokens` (
`user_id` INT(10) UNSIGNED NOT NULL,
`token_string` CHAR(64) NOT NULL,
`token_created` TIMESTAMP NOT NULL DEFAULT current_timestamp(),
UNIQUE INDEX `user_chat_token_string_unique` (`token_string`),
INDEX `user_chat_token_user_foreign` (`user_id`),
INDEX `user_chat_token_created_key` (`token_created`),
CONSTRAINT `user_chat_token_user_foreign`
FOREIGN KEY (`user_id`)
REFERENCES `msz_users` (`user_id`)
ON UPDATE CASCADE
ON DELETE CASCADE
) COLLATE='utf8mb4_bin' ENGINE=InnoDB;
");
}