-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change migration to include newly added constraints
- Loading branch information
Showing
1 changed file
with
26 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |