From 1cdc840048d0628fe2c02ee43d286aa6a4b5b7ff Mon Sep 17 00:00:00 2001 From: Kyle Date: Tue, 15 Oct 2024 13:54:47 -0400 Subject: [PATCH] Fix database column types --- mycodo/databases/models/controller.py | 4 ++-- mycodo/databases/models/dashboard.py | 2 +- mycodo/databases/models/function.py | 12 ++++++------ mycodo/databases/models/input.py | 4 ++-- mycodo/databases/models/misc.py | 4 ++-- mycodo/databases/models/notes.py | 2 +- mycodo/databases/models/output.py | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/mycodo/databases/models/controller.py b/mycodo/databases/models/controller.py index 0784165a3..308facecc 100644 --- a/mycodo/databases/models/controller.py +++ b/mycodo/databases/models/controller.py @@ -20,7 +20,7 @@ class CustomController(CRUDMixin, db.Model): is_activated = db.Column(db.Boolean, default=False) log_level_debug = db.Column(db.Boolean, default=False) - custom_options = db.Column(LONGTEXT, default='') + custom_options = db.Column(db.Text().with_variant(LONGTEXT, "mysql", "mariadb"), default='') def is_active(self): """ @@ -48,7 +48,7 @@ class FunctionChannel(CRUDMixin, db.Model): channel = db.Column(db.Integer, default=None) name = db.Column(db.Text, default='') - custom_options = db.Column(LONGTEXT, default='') + custom_options = db.Column(db.Text().with_variant(LONGTEXT, "mysql", "mariadb"), default='') def __repr__(self): return "<{cls}(id={s.id})>".format(s=self, cls=self.__class__.__name__) diff --git a/mycodo/databases/models/dashboard.py b/mycodo/databases/models/dashboard.py index 36281eb80..105d5f0ef 100644 --- a/mycodo/databases/models/dashboard.py +++ b/mycodo/databases/models/dashboard.py @@ -32,7 +32,7 @@ class Widget(CRUDMixin, db.Model): position_y = db.Column(db.Integer, default=999) width = db.Column(db.Integer, default=6) height = db.Column(db.Integer, default=6) - custom_options = db.Column(LONGTEXT, default='') + custom_options = db.Column(db.Text().with_variant(LONGTEXT, "mysql", "mariadb"), default='') # TODO: next major revision: delete all below, no longer used enable_header_buttons = db.Column(db.Boolean, default=True) diff --git a/mycodo/databases/models/function.py b/mycodo/databases/models/function.py index 8f95a3cdd..ca7d0d8ef 100644 --- a/mycodo/databases/models/function.py +++ b/mycodo/databases/models/function.py @@ -30,17 +30,17 @@ class Conditional(CRUDMixin, db.Model): is_activated = db.Column(db.Boolean, default=False) log_level_debug = db.Column(db.Boolean, default=False) - conditional_statement = db.Column(LONGTEXT, default='') - conditional_import = db.Column(LONGTEXT, default='') - conditional_initialize = db.Column(LONGTEXT, default='') - conditional_status = db.Column(LONGTEXT, default='') + conditional_statement = db.Column(db.Text().with_variant(LONGTEXT, "mysql", "mariadb"), default='') + conditional_import = db.Column(db.Text().with_variant(LONGTEXT, "mysql", "mariadb"), default='') + conditional_initialize = db.Column(db.Text().with_variant(LONGTEXT, "mysql", "mariadb"), default='') + conditional_status = db.Column(db.Text().with_variant(LONGTEXT, "mysql", "mariadb"), default='') period = db.Column(db.Float, default=60.0) start_offset = db.Column(db.Float, default=10.0) pyro_timeout = db.Column(db.Float, default=30.0) use_pylint = db.Column(db.Boolean, default=True) message_include_code = db.Column(db.Boolean, default=False) - custom_options = db.Column(LONGTEXT, default='') + custom_options = db.Column(db.Text().with_variant(LONGTEXT, "mysql", "mariadb"), default='') class ConditionalConditions(CRUDMixin, db.Model): @@ -137,7 +137,7 @@ class Actions(CRUDMixin, db.Model): function_type = db.Column(db.Text, default='') action_type = db.Column(db.Text, default='') # what action, such as 'email', 'execute command', 'flash LCD' - custom_options = db.Column(LONGTEXT, default='{}') + custom_options = db.Column(db.Text().with_variant(LONGTEXT, "mysql", "mariadb"), default='{}') # Actions pause_duration = db.Column(db.Float, default=5.0) diff --git a/mycodo/databases/models/input.py b/mycodo/databases/models/input.py index d60a716ca..fa0b9f373 100644 --- a/mycodo/databases/models/input.py +++ b/mycodo/databases/models/input.py @@ -87,7 +87,7 @@ class Input(CRUDMixin, db.Model): # The Things Network: Data Storage datetime = db.Column(db.DateTime, default=None) - custom_options = db.Column(LONGTEXT, default='') + custom_options = db.Column(db.Text().with_variant(LONGTEXT, "mysql", "mariadb"), default='') def is_active(self): """ @@ -115,7 +115,7 @@ class InputChannel(CRUDMixin, db.Model): channel = db.Column(db.Integer, default=None) name = db.Column(db.Text, default='') - custom_options = db.Column(LONGTEXT, default='') + custom_options = db.Column(db.Text().with_variant(LONGTEXT, "mysql", "mariadb"), default='') def __repr__(self): return "<{cls}(id={s.id})>".format(s=self, cls=self.__class__.__name__) diff --git a/mycodo/databases/models/misc.py b/mycodo/databases/models/misc.py index 0715e3607..2ee627253 100644 --- a/mycodo/databases/models/misc.py +++ b/mycodo/databases/models/misc.py @@ -54,8 +54,8 @@ class Misc(CRUDMixin, db.Model): brand_image_height = db.Column(db.Integer, default=55) favicon_display = db.Column(db.String(16), default='default') brand_favicon = db.Column(db.BLOB, default=b'') - custom_css = db.Column(LONGTEXT, default='') - custom_layout = db.Column(LONGTEXT, default='') + custom_css = db.Column(db.Text().with_variant(LONGTEXT, "mysql", "mariadb"), default='') + custom_layout = db.Column(db.Text().with_variant(LONGTEXT, "mysql", "mariadb"), default='') # Measurement database db_name = 'influxdb' # Default diff --git a/mycodo/databases/models/notes.py b/mycodo/databases/models/notes.py index 586d136ff..af6836e52 100644 --- a/mycodo/databases/models/notes.py +++ b/mycodo/databases/models/notes.py @@ -18,7 +18,7 @@ class Notes(CRUDMixin, db.Model): name = db.Column(db.Text, default=None) tags = db.Column(db.Text, default=None) files = db.Column(db.Text, default=None) - note = db.Column(LONGTEXT, default=None) + note = db.Column(db.Text().with_variant(LONGTEXT, "mysql", "mariadb"), default=None) def __repr__(self): return "<{cls}(id={s.id})>".format(s=self, cls=self.__class__.__name__) diff --git a/mycodo/databases/models/output.py b/mycodo/databases/models/output.py index d7e019ede..04707dba0 100644 --- a/mycodo/databases/models/output.py +++ b/mycodo/databases/models/output.py @@ -34,7 +34,7 @@ class Output(CRUDMixin, db.Model): uart_location = db.Column(db.Text, default=None) # Device location for UART communication baud_rate = db.Column(db.Integer, default=None) # Baud rate for UART communication - custom_options = db.Column(LONGTEXT, default='') + custom_options = db.Column(db.Text().with_variant(LONGTEXT, "mysql", "mariadb"), default='') # TODO; Delete at next major version # No longer used @@ -82,7 +82,7 @@ class OutputChannel(CRUDMixin, db.Model): channel = db.Column(db.Integer, default=None) name = db.Column(db.Text, default='') - custom_options = db.Column(LONGTEXT, default='') + custom_options = db.Column(db.Text().with_variant(LONGTEXT, "mysql", "mariadb"), default='') def __repr__(self): return "<{cls}(id={s.id})>".format(s=self, cls=self.__class__.__name__)