forked from Skynet/discord-bot
feat: sql to migrate to new format
This commit is contained in:
parent
ed4c46e81d
commit
d58d837940
1 changed files with 18 additions and 0 deletions
18
db/migrations/3_minecraft-server-migrate.sql
Normal file
18
db/migrations/3_minecraft-server-migrate.sql
Normal file
|
@ -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;
|
Loading…
Reference in a new issue