mirror of https://gitlab.com/litecord/litecord.git
manage: add dummy migration command
This commit is contained in:
parent
a1a914dc87
commit
c3210bf5b0
|
|
@ -0,0 +1 @@
|
||||||
|
from .command import setup as migration
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
async def migrate_cmd(app, args):
|
||||||
|
"""Main migration command.
|
||||||
|
|
||||||
|
This makes sure the database
|
||||||
|
is updated.
|
||||||
|
"""
|
||||||
|
print('not implemented yet')
|
||||||
|
|
||||||
|
|
||||||
|
def setup(subparser):
|
||||||
|
migrate_parser = subparser.add_parser(
|
||||||
|
'migrate',
|
||||||
|
help='Run migration tasks',
|
||||||
|
description=migrate_cmd.__doc__
|
||||||
|
)
|
||||||
|
|
||||||
|
migrate_parser.set_defaults(func=migrate_cmd)
|
||||||
|
|
@ -1,8 +1,14 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import argparse
|
||||||
|
from sys import argv
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
from logbook import Logger
|
||||||
|
|
||||||
from run import init_app_managers, init_app_db
|
from run import init_app_managers, init_app_db
|
||||||
|
from manage.cmd.migration import migration
|
||||||
|
|
||||||
|
log = Logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|
@ -18,6 +24,15 @@ class FakeApp:
|
||||||
presence = None
|
presence = None
|
||||||
|
|
||||||
|
|
||||||
|
def init_parser():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
subparser = parser.add_subparsers(help='operations')
|
||||||
|
|
||||||
|
migration(subparser)
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
def main(config):
|
def main(config):
|
||||||
"""Start the script"""
|
"""Start the script"""
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
|
@ -27,4 +42,17 @@ def main(config):
|
||||||
loop.run_until_complete(init_app_db(app))
|
loop.run_until_complete(init_app_db(app))
|
||||||
init_app_managers(app)
|
init_app_managers(app)
|
||||||
|
|
||||||
print(app)
|
# initialize argparser
|
||||||
|
parser = init_parser()
|
||||||
|
|
||||||
|
try:
|
||||||
|
if len(argv) < 2:
|
||||||
|
parser.print_help()
|
||||||
|
return
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
loop.run_until_complete(args.func(app, args))
|
||||||
|
except Exception:
|
||||||
|
log.exception('error while running command')
|
||||||
|
finally:
|
||||||
|
loop.run_until_complete(app.db.close())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue