示例#1
0
 def __init__(self):
     uri = 'postgres://*****:*****@localhost/fluidinfo-unit-test'
     uri = os.environ.get('FLUIDDB_DB', uri)
     databases = [{'name': 'main',
                   'uri': uri,
                   'schema': main.createSchema()}]
     super(MainDatabaseResource, self).__init__(databases)
示例#2
0
 def run(self, database_uri):
     setConfig(setupConfig(None))
     setupLogging(self.outf)
     store = setupStore(database_uri, 'main')
     schema = main.createSchema()
     logging.info('Creating schema.')
     patchDatabase(store, schema)
     logging.info('Creating system data.')
     bootstrapSystemData(store)
     logging.info('Creating web admin data.')
     bootstrapWebAdminData()
示例#3
0
 def run(self, database_uri):
     setConfig(setupConfig(None))
     setupLogging(self.outf)
     store = setupStore(database_uri, 'main')
     schema = main.createSchema()
     logging.info('Creating schema.')
     patchDatabase(store, schema)
     logging.info('Creating system data.')
     bootstrapSystemData(store)
     logging.info('Creating web admin data.')
     bootstrapWebAdminData()
示例#4
0
 def run(self, database_uri):
     setConfig(setupConfig(None))
     setupLogging(self.outf)
     store = setupStore(database_uri, 'main')
     schema = main.createSchema()
     status = getPatchStatus(store, schema)
     if status.unappliedPatches:
         patches = ', '.join('patch_%d' % version
                             for version in status.unappliedPatches)
         logging.info('Unapplied patches: %s' % patches)
         sys.exit(1)
     if status.unknownPatches:
         patches = ', '.join('patch_%d' % version
                             for version in status.unknownPatches)
         logging.info('Unknown patches: %s' % patches)
         sys.exit(2)
     if not status.unappliedPatches and not status.unknownPatches:
         logging.info('Database is up-to-date.')
         sys.exit(0)
示例#5
0
 def run(self, database_uri):
     setConfig(setupConfig(None))
     setupLogging(self.outf)
     store = setupStore(database_uri, 'main')
     schema = main.createSchema()
     status = getPatchStatus(store, schema)
     if status.unknownPatches:
         unknownPatches = ', '.join(
             'patch_%d' % version for version in status.unknownPatches)
         logging.critical('Database has unknown patches: %s',
                          unknownPatches)
         return 1
     if status.unappliedPatches:
         unappliedPatches = ', '.join(
             'patch_%d' % version for version in status.unappliedPatches)
         logging.info('Applying patches: %s', unappliedPatches)
         patchDatabase(store, schema)
     else:
         logging.info('Database is up-to-date.')
示例#6
0
 def run(self, database_uri):
     setConfig(setupConfig(None))
     setupLogging(self.outf)
     store = setupStore(database_uri, 'main')
     schema = main.createSchema()
     status = getPatchStatus(store, schema)
     if status.unappliedPatches:
         patches = ', '.join('patch_%d' % version
                             for version in status.unappliedPatches)
         logging.info('Unapplied patches: %s' % patches)
         sys.exit(1)
     if status.unknownPatches:
         patches = ', '.join('patch_%d' % version
                             for version in status.unknownPatches)
         logging.info('Unknown patches: %s' % patches)
         sys.exit(2)
     if not status.unappliedPatches and not status.unknownPatches:
         logging.info('Database is up-to-date.')
         sys.exit(0)
示例#7
0
 def run(self, database_uri):
     setConfig(setupConfig(None))
     setupLogging(self.outf)
     store = setupStore(database_uri, 'main')
     schema = main.createSchema()
     status = getPatchStatus(store, schema)
     if status.unknownPatches:
         unknownPatches = ', '.join('patch_%d' % version
                                    for version in status.unknownPatches)
         logging.critical('Database has unknown patches: %s',
                          unknownPatches)
         return 1
     if status.unappliedPatches:
         unappliedPatches = ', '.join(
             'patch_%d' % version for version in status.unappliedPatches)
         logging.info('Applying patches: %s', unappliedPatches)
         patchDatabase(store, schema)
     else:
         logging.info('Database is up-to-date.')
示例#8
0
def verifyStore():
    """Ensure that the patch level in the database matches the application.

    @raise RuntimeError: Raised if there are unknown or unapplied patches.
    """
    from fluiddb.schema.main import createSchema
    from fluiddb.scripts.schema import getPatchStatus

    schema = createSchema()
    zstorm = getUtility(IZStorm)
    store = zstorm.get('main')
    try:
        status = getPatchStatus(store, schema)
        if status.unappliedPatches:
            patches = ', '.join('patch_%d' % version
                                for version in status.unappliedPatches)
            raise RuntimeError('Database has unapplied patches: %s' % patches)
        if status.unknownPatches:
            patches = ', '.join('patch_%d' % version
                                for version in status.unknownPatches)
            raise RuntimeError('Database has unknown patches: %s' % patches)
    finally:
        zstorm.remove(store)
        store.close()