Commit bcd24c38 authored by echel0n's avatar echel0n

Fixed issue with database upgrades, refactored database initialization to...

Fixed issue with database upgrades, refactored database initialization to happen after migrations and upgrades are performed
parent 17d5cbde
......@@ -311,14 +311,18 @@ class Core(object):
self.log.info("Performing integrity check on {} database".format(db.name))
db.integrity_check()
# migrate database
self.log.info("Performing migrations on {} database".format(db.name))
db.migrate()
# upgrade database
self.log.info("Performing upgrades on {} database".format(db.name))
db.upgrade()
# upgrade database
self.log.info("Performing initialization on {} database".format(db.name))
db.initialize()
# migrate database
self.log.info("Performing migrations on {} database".format(db.name))
db.migrate()
# cleanup
self.log.info("Performing cleanup on {} database".format(db.name))
db.cleanup()
......
......@@ -36,7 +36,6 @@ from sqlalchemy import create_engine, event, inspect, MetaData, Index, TypeDecor
from sqlalchemy.engine import Engine, reflection
from sqlalchemy.exc import OperationalError
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.serializer import loads, dumps
from sqlalchemy.orm import sessionmaker, mapper, scoped_session
from sqlalchemy.sql.ddl import CreateTable, CreateIndex
......
......@@ -27,7 +27,6 @@ class CacheDB(SRDatabase):
def __init__(self, db_type, db_prefix, db_host, db_port, db_username, db_password):
super(CacheDB, self).__init__('cache', db_type, db_prefix, db_host, db_port, db_username, db_password)
self.initialize()
def initialize(self):
self.base.metadata.create_all(self.engine)
......
......@@ -120,7 +120,6 @@ class ConfigDB(SRDatabase):
def __init__(self, db_type, db_prefix, db_host, db_port, db_username, db_password):
super(ConfigDB, self).__init__('config', db_type, db_prefix, db_host, db_port, db_username, db_password)
self.initialize()
def initialize(self):
self.base.metadata.create_all(self.engine)
......
......@@ -32,7 +32,6 @@ class MainDB(SRDatabase):
def __init__(self, db_type, db_prefix, db_host, db_port, db_username, db_password):
super(MainDB, self).__init__('main', db_type, db_prefix, db_host, db_port, db_username, db_password)
self.initialize()
def initialize(self):
self.base.metadata.create_all(self.engine)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment