Example #1
0
async def _clear_dbs(root):
    # make sure to completely clear db before carrying on...
    for _, db in root:
        if not IDatabase.providedBy(db):
            continue
        storage = db.storage
        if IPostgresStorage.providedBy(storage) or ICockroachStorage.providedBy(storage):
            async with storage.pool.acquire() as conn:
                await conn.execute(
                    """
DELETE from {}
WHERE zoid != '{}' AND zoid != '{}'
""".format(
                        storage._objects_table_name, ROOT_ID, TRASHED_ID
                    )
                )
                await conn.execute(
                    """
SELECT 'DROP INDEX ' || string_agg(indexrelid::regclass::text, ', ')
   FROM   pg_index  i
   LEFT   JOIN pg_depend d ON d.objid = i.indexrelid
                          AND d.deptype = 'i'
   WHERE  i.indrelid = '{}'::regclass
   AND    d.objid IS NULL
""".format(
                        storage._objects_table_name
                    )
                )
Example #2
0
async def _clear_dbs(root):
    # make sure to completely clear db before carrying on...
    async for db in iter_databases(root):
        storage = db.storage
        if IPostgresStorage.providedBy(storage) or ICockroachStorage.providedBy(storage):
            async with storage.pool.acquire() as conn:
                await conn.execute('''
DELETE from {}
WHERE zoid != '{}' AND zoid != '{}'
'''.format(storage._objects_table_name, ROOT_ID, TRASHED_ID))
Example #3
0
async def _clear_dbs(root):
    # make sure to completely clear db before carrying on...
    async for db in iter_databases(root):
        storage = db.storage
        if IPostgresStorage.providedBy(
                storage) or ICockroachStorage.providedBy(storage):
            async with storage.pool.acquire() as conn:
                await conn.execute('''
DELETE from {}
WHERE zoid != '{}' AND zoid != '{}'
'''.format(storage._objects_table_name, ROOT_ID, TRASHED_ID))
Example #4
0
async def db_initialized(event):
    '''
    Initialize additional pg indexes
    '''
    storage = event.database.storage
    if not IPostgresStorage.providedBy(storage) or ICockroachStorage.providedBy(storage):
        return

    # create json data indexes
    async with storage.lock:
        for statement in statements:
            await storage.read_conn.execute(
                statement.format(storage._objects_table_name))
Example #5
0
def supports_ordering(storage):
    if not app_settings.get("store_json", False):
        return False
    return IPostgresStorage.providedBy(
        storage) and not ICockroachStorage.providedBy(storage)