mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-04-27 16:10:32 +00:00
add lxmf rssi, snr and quality to database
This commit is contained in:
parent
45da6e749e
commit
0822bbf60d
2 changed files with 37 additions and 2 deletions
13
database.py
13
database.py
|
|
@ -3,7 +3,7 @@ from datetime import datetime, timezone
|
|||
from peewee import *
|
||||
from playhouse.migrate import migrate as migrate_database, SqliteMigrator
|
||||
|
||||
latest_version = 2 # increment each time new database migrations are added
|
||||
latest_version = 3 # increment each time new database migrations are added
|
||||
database = DatabaseProxy() # use a proxy object, as we will init real db client inside meshchat.py
|
||||
migrator = SqliteMigrator(database)
|
||||
|
||||
|
|
@ -18,6 +18,14 @@ def migrate(current_version):
|
|||
migrator.add_column("lxmf_messages", 'next_delivery_attempt_at', LxmfMessage.next_delivery_attempt_at),
|
||||
)
|
||||
|
||||
# migrate to version 3
|
||||
if current_version < 3:
|
||||
migrate_database(
|
||||
migrator.add_column("lxmf_messages", 'rssi', LxmfMessage.rssi),
|
||||
migrator.add_column("lxmf_messages", 'snr', LxmfMessage.snr),
|
||||
migrator.add_column("lxmf_messages", 'quality', LxmfMessage.quality),
|
||||
)
|
||||
|
||||
return latest_version
|
||||
|
||||
|
||||
|
|
@ -71,6 +79,9 @@ class LxmfMessage(BaseModel):
|
|||
content = TextField()
|
||||
fields = TextField() # json string
|
||||
timestamp = FloatField() # timestamp of when the message was originally created (before ever being sent)
|
||||
rssi = IntegerField(null=True)
|
||||
snr = FloatField(null=True)
|
||||
quality = FloatField(null=True)
|
||||
created_at = DateTimeField(default=lambda: datetime.now(timezone.utc))
|
||||
updated_at = DateTimeField(default=lambda: datetime.now(timezone.utc))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue