From d58d837940006538dc479efdb19e04f9f375dbd0 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Mon, 3 Jun 2024 01:19:14 +0100 Subject: [PATCH] feat: sql to migrate to new format --- db/migrations/3_minecraft-server-migrate.sql | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 db/migrations/3_minecraft-server-migrate.sql diff --git a/db/migrations/3_minecraft-server-migrate.sql b/db/migrations/3_minecraft-server-migrate.sql new file mode 100644 index 0000000..928c13d --- /dev/null +++ b/db/migrations/3_minecraft-server-migrate.sql @@ -0,0 +1,18 @@ +-- Create the new table +CREATE TABLE IF NOT EXISTS minecraft +( + server_discord integer not null, + server_minecraft text not null, + PRIMARY KEY (server_discord, server_minecraft), + FOREIGN KEY (server_discord) REFERENCES servers (server) +); + +-- Import in the data +INSERT INTO minecraft (server_discord, server_minecraft) +SELECT server, server_minecraft +FROM servers +where server_minecraft is not null; + +-- delete the col in teh server table +ALTER TABLE servers + DROP COLUMN server_minecraft; \ No newline at end of file