Skip to content

Commit

Permalink
Fix database column types
Browse files Browse the repository at this point in the history
  • Loading branch information
kizniche committed Oct 15, 2024
1 parent 3e0bb72 commit 1cdc840
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions mycodo/databases/models/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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__)
Expand Down
2 changes: 1 addition & 1 deletion mycodo/databases/models/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions mycodo/databases/models/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions mycodo/databases/models/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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__)
Expand Down
4 changes: 2 additions & 2 deletions mycodo/databases/models/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mycodo/databases/models/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
4 changes: 2 additions & 2 deletions mycodo/databases/models/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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__)
Expand Down

0 comments on commit 1cdc840

Please sign in to comment.