add aerich

This commit is contained in:
Corban-Lee Jones 2024-12-11 20:04:30 +00:00
parent 5d551b3dd8
commit 91d96d1bcb
4 changed files with 19 additions and 5 deletions

View File

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

14
bot.py
View File

@ -21,6 +21,15 @@ log = logging.getLogger(__name__)
BASE_DIR = Path(__file__).resolve().parent
DATA_DIR = getenv("SPIFFO__DATA_FOLDER_PATH")
TORTOISE_ORM = {
"connections": { "default": f"sqlite://{str(DATA_DIR)}/db.sqlite" },
"apps": {
"models": {
"models": ["utils.models", "aerich.models"],
"default_connection": "default"
}
}
}
class DiscordBot(commands.Bot):
@ -117,10 +126,7 @@ async def main():
bot_token = get_bot_token()
# Open database connection
await Tortoise.init(
db_url= f"sqlite://{str(DATA_DIR)}/db.sqlite",
modules={"models": ["utils.models"]}
)
await Tortoise.init(config=TORTOISE_ORM)
await Tortoise.generate_schemas()
async with DiscordBot(debug_mode) as bot:

4
pyproject.toml Normal file
View File

@ -0,0 +1,4 @@
[tool.aerich]
tortoise_orm = "bot.TORTOISE_ORM"
location = "./migrations"
src_folder = "./."

View File

@ -1,3 +1,4 @@
aerich==0.8.0
aiofiles==24.1.0
aiohappyeyeballs==2.4.4
aiohttp==3.11.9
@ -5,9 +6,11 @@ aiosignal==1.3.1
aiosqlite==0.20.0
annotated-types==0.7.0
anyio==4.7.0
asyncclick==8.1.7.2
attrs==24.2.0
bump2version==1.0.1
certifi==2024.8.30
dictdiffer==0.9.0
discord.py==2.4.0
frozenlist==1.5.0
h11==0.14.0
@ -24,6 +27,7 @@ python-dotenv==1.0.1
pytz==2024.2
rcon==2.4.9
sniffio==1.3.1
tomlkit==0.13.2
tortoise-orm==0.22.1
typing_extensions==4.12.2
yarl==1.18.3