diff --git a/eos/db/migrations/upgrade47.py b/eos/db/migrations/upgrade47.py index 7aa5d5ca5..2d9cb7291 100644 --- a/eos/db/migrations/upgrade47.py +++ b/eos/db/migrations/upgrade47.py @@ -1,19 +1,36 @@ """ -Migration 28 +Migration 46 -- adds baseItemID and mutaplasmidID to modules table +- add support for server selection for SSO characters """ import sqlalchemy - +tmpTable = """ + CREATE TABLE ssoCharacterTemp ( + ID INTEGER NOT NULL, + client VARCHAR NOT NULL, + characterID INTEGER NOT NULL, + characterName VARCHAR NOT NULL, + refreshToken VARCHAR NOT NULL, + accessToken VARCHAR NOT NULL, + accessTokenExpires DATETIME NOT NULL, + created DATETIME, + modified DATETIME, + server VARCHAR, + PRIMARY KEY (ID), + CONSTRAINT "uix_client_server_characterID" UNIQUE (client, server, characterID), + CONSTRAINT "uix_client_server_characterName" UNIQUE (client, server, characterName) + ) +""" def upgrade(saveddata_engine): try: saveddata_engine.execute("SELECT server FROM ssoCharacter LIMIT 1") except sqlalchemy.exc.DatabaseError: - saveddata_engine.execute("ALTER TABLE ssoCharacter ADD COLUMN server VARCHAR;") - saveddata_engine.execute("UPDATE ssoCharacter SET server = 'Tranquility';") - - - - # update all characters to TQ + saveddata_engine.execute(tmpTable) + saveddata_engine.execute( + "INSERT INTO ssoCharacterTemp (ID, client, characterID, characterName, refreshToken, accessToken, accessTokenExpires, created, modified, server) " + "SELECT ID, client, characterID, characterName, refreshToken, accessToken, accessTokenExpires, created, modified, 'Tranquility' " + "FROM ssoCharacter") + saveddata_engine.execute("DROP TABLE ssoCharacter") + saveddata_engine.execute("ALTER TABLE ssoCharacterTemp RENAME TO ssoCharacter")