Skip to content

Commit

Permalink
New Version 1.3.3
Browse files Browse the repository at this point in the history
- #109 new columns overwritten by renaming script
  • Loading branch information
OllisGit committed Jan 25, 2021
1 parent c6dfc23 commit e89872f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
33 changes: 32 additions & 1 deletion octoprint_SpoolManager/DatabaseManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

FORCE_CREATE_TABLES = False

CURRENT_DATABASE_SCHEME_VERSION = 4
CURRENT_DATABASE_SCHEME_VERSION = 5

# List all Models
MODELS = [PluginMetaDataModel, SpoolModel]
Expand Down Expand Up @@ -176,8 +176,39 @@ def _upgradeDatabase(self,currentDatabaseSchemeVersion, targetDatabaseSchemeVers

def _upgradeFrom4To5(self):
self._logger.info(" Starting 4 -> 5")
# What is changed:
# SpoolModel (needed, because lats script created a new table and altering was already done
# - materialCharacteristic = CharField(null=True, index=True) # strong, soft,... # since V4: new
# - material = CharField(null=True, index=True) # since V4: added index
# - vendor = CharField(null=True, index=True) # since V4: added index
connection = sqlite3.connect(self._databaseSettings.fileLocation)
cursor = connection.cursor()

sql = """
PRAGMA foreign_keys=off;
BEGIN TRANSACTION;
ALTER TABLE 'spo_spoolmodel' ADD 'updated' DATETIME;
ALTER TABLE 'spo_spoolmodel' ADD 'originator' CHAR(60);
ALTER TABLE 'spo_spoolmodel' ADD 'materialCharacteristic' VARCHAR(255);
ALTER TABLE 'spo_spoolmodel' ADD 'isActive' INTEGER;
UPDATE 'spo_spoolmodel' SET isActive=1;
CREATE INDEX spoolmodel_materialCharacteristic ON spo_spoolmodel (materialCharacteristic);
CREATE INDEX spoolmodel_material ON spo_spoolmodel (material);
CREATE INDEX spoolmodel_vendor ON spo_spoolmodel (vendor);
UPDATE 'spo_pluginmetadatamodel' SET value=5 WHERE key='databaseSchemeVersion';
COMMIT;
PRAGMA foreign_keys=on;
"""
cursor.executescript(sql)

connection.close()

self._logger.info(" Successfully 4 -> 5")
pass


def _upgradeFrom3To4(self):
self._logger.info(" Starting 3 -> 4")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
#
plugin_version = "1.3.3-dev"
plugin_version = "1.3.3"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit e89872f

Please sign in to comment.