Skip to content

Commit

Permalink
Change migration to include newly added constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkFenX committed Feb 26, 2024
1 parent fb45736 commit 9f5a649
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions eos/db/migrations/upgrade47.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 9f5a649

Please sign in to comment.