remove that stupid package aerich, it's terrible!

This commit is contained in:
Corban-Lee Jones 2024-12-11 22:55:08 +00:00
parent 55304170b1
commit 825843ed86
5 changed files with 18 additions and 11 deletions

View File

@ -11,7 +11,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Debug environment variable flag.
- Command to build player data from existing log files.
- Database migration management with the aerich package.
### Changed

View File

@ -13,4 +13,4 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY . /app/
CMD ["sh", "-c", "aerich upgrade && python bot.py"]
CMD ["python", "bot.py"]

2
bot.py
View File

@ -25,7 +25,7 @@ TORTOISE_ORM = {
"connections": { "default": f"sqlite://{str(DATA_DIR)}/db.sqlite" },
"apps": {
"models": {
"models": ["utils.models", "aerich.models"],
"models": ["utils.models"],
"default_connection": "default"
}
}

View File

@ -3,21 +3,30 @@ from tortoise import BaseDBAsyncClient
async def upgrade(db: BaseDBAsyncClient) -> str:
return """
CREATE TABLE IF NOT EXISTS "players" (
CREATE TABLE IF NOT EXISTS "ingame_coordinates" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"x" INT NOT NULL,
"y" INT NOT NULL,
"z" INT NOT NULL
);
CREATE TABLE IF NOT EXISTS "players" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"username" VARCHAR(20) NOT NULL UNIQUE,
"last_connection" TIMESTAMP,
"last_disconnection" TIMESTAMP,
"play_time_seconds" INT NOT NULL DEFAULT 0,
"is_dead" INT NOT NULL DEFAULT 0
) /* */;
CREATE TABLE IF NOT EXISTS "player_deaths" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"coordinate_x" INT NOT NULL,
"coordinate_y" INT NOT NULL,
"coordinate_z" INT NOT NULL,
"cause" VARCHAR(32) NOT NULL,
"timestamp" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
"coordinates_id" INT NOT NULL REFERENCES "ingame_coordinates" ("id") ON DELETE CASCADE,
"player_id" INT NOT NULL REFERENCES "players" ("id") ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS "player_session" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"connected_at" TIMESTAMP NOT NULL,
"disconnected_at" TIMESTAMP NOT NULL,
"connected_coords_id" INT NOT NULL REFERENCES "ingame_coordinates" ("id") ON DELETE CASCADE,
"disconnected_coords_id" INT REFERENCES "ingame_coordinates" ("id") ON DELETE CASCADE,
"player_id" INT NOT NULL REFERENCES "players" ("id") ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS "steam_profile_summary" (

View File

@ -1,4 +1,3 @@
aerich==0.8.0
aiofiles==24.1.0
aiohappyeyeballs==2.4.4
aiohttp==3.11.9