X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcore%2Fdatabase.py;h=939abc6a640ba1053c8721182fd434263c3e5d58;hb=30d94690e5a7220fdc084139b594e0da383563c5;hp=eca08e9c8df63bd26baa7e170fab422d0ce2188a;hpb=5ac7c081ca13495185ecf6bdf302c16c25a4b759;p=osm%2FMON.git diff --git a/osm_mon/core/database.py b/osm_mon/core/database.py index eca08e9..939abc6 100644 --- a/osm_mon/core/database.py +++ b/osm_mon/core/database.py @@ -23,11 +23,14 @@ ## import logging +import os import uuid from peewee import CharField, TextField, FloatField, Model, AutoField, Proxy +from peewee_migrate import Router from playhouse.db_url import connect +from osm_mon import migrations from osm_mon.core.config import Config log = logging.getLogger(__name__) @@ -50,7 +53,7 @@ class VimCredentials(BaseModel): user = CharField() password = CharField() tenant_name = CharField() - config = TextField(default='{}') + config = TextField() class Alarm(BaseModel): @@ -72,7 +75,8 @@ class DatabaseManager: def create_tables(self) -> None: with db.atomic(): - db.create_tables([VimCredentials, Alarm]) + router = Router(db, os.path.dirname(migrations.__file__)) + router.run() def get_credentials(self, vim_uuid: str = None) -> VimCredentials: with db.atomic():