Commit 03b9e296 authored by Romain Courteaud's avatar Romain Courteaud

Autoincrement status id.

Use milliseconds timestamp
parent df2aed92
import peewee import peewee
from playhouse.migrate import migrate, SqliteMigrator from playhouse.migrate import migrate, SqliteMigrator
from playhouse.sqlite_ext import SqliteExtDatabase from playhouse.sqlite_ext import SqliteExtDatabase
import datetime
class LogDB: class LogDB:
...@@ -17,11 +18,15 @@ class LogDB: ...@@ -17,11 +18,15 @@ class LogDB:
# This store the start, stop, loop time of the bot # This store the start, stop, loop time of the bot
# All other tables point to it to be able to group some info # All other tables point to it to be able to group some info
class Status(BaseModel): class Status(BaseModel):
# Ensure the id is always incremented
id = peewee.AutoField()
text = peewee.TextField() text = peewee.TextField()
# date is in UTC
# https://www.sqlite.org/lang_datefunc.html
timestamp = peewee.TimestampField( timestamp = peewee.TimestampField(
constraints=[peewee.SQL("DEFAULT now")] # Store millisecond resolution
resolution=3,
# date is in UTC
utc=True,
default=datetime.datetime.now,
) )
# Store the configuration modification # Store the configuration modification
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment