matrix-reportbot/migrations/migration_1.py
Kumi 2bbc6a33ca
Moving migrations to subdirectory
Add option for custom system messages per room
Fixing some methods in store
2023-04-24 08:48:59 +00:00

32 lines
No EOL
801 B
Python

# Initial migration, token usage logging
from datetime import datetime
def migration(conn):
with conn.cursor() as cursor:
cursor.execute(
"""
CREATE TABLE IF NOT EXISTS token_usage (
message_id TEXT PRIMARY KEY,
room_id TEXT NOT NULL,
tokens INTEGER NOT NULL,
timestamp TIMESTAMP NOT NULL
)
"""
)
cursor.execute(
"""
CREATE TABLE IF NOT EXISTS migrations (
id INTEGER NOT NULL,
timestamp TIMESTAMP NOT NULL
)
"""
)
cursor.execute(
"INSERT INTO migrations (id, timestamp) VALUES (1, ?)",
(datetime.now(),)
)
conn.commit()