Files
Aurora.3/SQL/migrate-2017/V021__combine_tables.sql
Werner a69a7316ab Condense Database Migrations (#17103)
* Condense Database Migrations

Condenses the Database Migrations into a new initial schema.
Also adds some instructions to the Database Readme for existing setups.

* Update readme/delete changed migrations since pr creation

* Reworks a bit how the previous migrations are handled and updates the instructions accordingly

* Expand the readme with baseline/migrate

---------

Co-authored-by: Werner <Arrow768@users.noreply.github.com>
2023-08-19 22:32:13 +02:00

29 lines
824 B
SQL

--
-- Combines the ss13_admin and ss13_player table
--
ALTER TABLE `ss13_player`
ADD COLUMN `rank` VARCHAR(32) NULL DEFAULT NULL AFTER `migration_status`,
ADD COLUMN `flags` INT(32) UNSIGNED NOT NULL DEFAULT '0',
ADD COLUMN `discord_id` VARCHAR(45) NULL DEFAULT NULL AFTER `flags`;
UPDATE `ss13_admin`
SET `flags` = 0
WHERE `rank` = "Removed";
UPDATE `ss13_player`
INNER JOIN `ss13_admin` ON ss13_admin.ckey = ss13_player.ckey
SET
ss13_player.rank = ss13_admin.rank,
ss13_player.flags = ss13_admin.flags,
ss13_player.discord_id = ss13_admin.discord_id;
UPDATE `ss13_player`
SET `rank` = NULL
WHERE `rank` = "Removed";
ALTER TABLE `ss13_admin`
DROP FOREIGN KEY `ckey`;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
DROP TABLE `ss13_admin`;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;