From 6153e11834e872566b525c5a9d5b30d32a351bac Mon Sep 17 00:00:00 2001 From: Julien Loizelet Date: Fri, 9 Feb 2024 18:11:34 +0900 Subject: [PATCH] fix(sql): Add length to machine_id field for mysql compatibility (#17) --- .gitignore | 5 ++++- src/cscapi/sql_storage.py | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index b1baa0d..f805a7e 100644 --- a/.gitignore +++ b/.gitignore @@ -144,4 +144,7 @@ src/cscapi/_version.py *.db #vscode -.vscode \ No newline at end of file +.vscode + +#ddev +.ddev \ No newline at end of file diff --git a/src/cscapi/sql_storage.py b/src/cscapi/sql_storage.py index 870f6ce..39c8824 100644 --- a/src/cscapi/sql_storage.py +++ b/src/cscapi/sql_storage.py @@ -9,6 +9,7 @@ ForeignKey, Integer, TEXT, + String, create_engine, delete, update, @@ -50,7 +51,7 @@ class MachineDBModel(Base): __tablename__ = "machine_models" id = Column(Integer, primary_key=True, autoincrement=True) - machine_id = Column(TEXT, unique=True) + machine_id = Column(String(256), unique=True) token = Column(TEXT) password = Column(TEXT) scenarios = Column(TEXT) @@ -109,7 +110,7 @@ class SignalDBModel(Base): alert_id = Column(Integer, primary_key=True, autoincrement=True) created_at = Column(TEXT) - machine_id = Column(TEXT) + machine_id = Column(String(256)) scenario_version = Column(TEXT, nullable=True) message = Column(TEXT, nullable=True) uuid = Column(TEXT)