mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 18:02:41 +02:00
💄 — Use an argos server command to do alembic migrations
This commit is contained in:
parent
f976905433
commit
8875c704ee
2 changed files with 18 additions and 1 deletions
|
@ -4,6 +4,8 @@ from functools import wraps
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import uvicorn
|
import uvicorn
|
||||||
|
from alembic import command
|
||||||
|
from alembic.config import Config
|
||||||
|
|
||||||
from argos import logging
|
from argos import logging
|
||||||
from argos.agent import ArgosAgent
|
from argos.agent import ArgosAgent
|
||||||
|
@ -152,5 +154,20 @@ async def reload_config():
|
||||||
click.echo(f"{changed['vanished']} tasks deleted")
|
click.echo(f"{changed['vanished']} tasks deleted")
|
||||||
|
|
||||||
|
|
||||||
|
@server.command()
|
||||||
|
@coroutine
|
||||||
|
async def migrate():
|
||||||
|
"""Run database migrations
|
||||||
|
"""
|
||||||
|
# The imports are made here otherwise the agent will need server configuration files.
|
||||||
|
from argos.server.settings import get_app_settings
|
||||||
|
|
||||||
|
settings = get_app_settings()
|
||||||
|
|
||||||
|
alembic_cfg = Config("alembic.ini")
|
||||||
|
alembic_cfg.set_main_option("sqlalchemy.url", settings.database_url)
|
||||||
|
command.upgrade(alembic_cfg, "head")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
cli()
|
cli()
|
||||||
|
|
|
@ -8,7 +8,7 @@ PartOf=postgresql.service
|
||||||
[Service]
|
[Service]
|
||||||
User=www-data
|
User=www-data
|
||||||
WorkingDirectory=/var/www/argos/
|
WorkingDirectory=/var/www/argos/
|
||||||
ExecStartPre=/var/www/argos/venv/bin/alembic upgrade head
|
ExecStartPre=/var/www/argos/venv/bin/argos server migrate
|
||||||
ExecStartPre=/var/www/argos/venv/bin/argos server reload-config
|
ExecStartPre=/var/www/argos/venv/bin/argos server reload-config
|
||||||
ExecStart=/var/www/argos/venv/bin/argos server start
|
ExecStart=/var/www/argos/venv/bin/argos server start
|
||||||
ExecReload=/var/www/argos/venv/bin/argos server reload
|
ExecReload=/var/www/argos/venv/bin/argos server reload
|
||||||
|
|
Loading…
Reference in a new issue