add aerich upgrade before init
This commit is contained in:
parent
1195aef57e
commit
1f27f2f78c
|
@ -5,6 +5,8 @@ from tortoise import Tortoise
|
||||||
|
|
||||||
from mobilizon_reshare.config.publishers import publisher_names
|
from mobilizon_reshare.config.publishers import publisher_names
|
||||||
from mobilizon_reshare.storage.query.write import update_publishers
|
from mobilizon_reshare.storage.query.write import update_publishers
|
||||||
|
from aerich import Command
|
||||||
|
from mobilizon_reshare.aerich_conf.database import TORTOISE_ORM
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -17,7 +19,16 @@ class MoReDB:
|
||||||
if not self.is_init:
|
if not self.is_init:
|
||||||
self.path.parent.mkdir(parents=True, exist_ok=True)
|
self.path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
async def __implement_db_changes__(self):
|
||||||
|
print('implementing db changes')
|
||||||
|
command = Command(tortoise_config=TORTOISE_ORM, app='models',
|
||||||
|
location='./')
|
||||||
|
await command.init()
|
||||||
|
await command.upgrade()
|
||||||
|
|
||||||
|
|
||||||
async def setup(self):
|
async def setup(self):
|
||||||
|
await self.__implement_db_changes__()
|
||||||
await Tortoise.init(
|
await Tortoise.init(
|
||||||
db_url=f"sqlite:///{self.path}",
|
db_url=f"sqlite:///{self.path}",
|
||||||
modules={
|
modules={
|
||||||
|
|
Loading…
Reference in New Issue