##// END OF EJS Templates
fix(db-migrate): enforce gc collection to optimize memory usage
fix(db-migrate): enforce gc collection to optimize memory usage

File last commit:

r5504:44ad8d20 default
r5504:44ad8d20 default
Show More
115_version_5_1_0.py
53 lines | 1.3 KiB | text/x-python | PythonLexer
chore: added excplicit db-migrate to update hooks for 5.X rel
r5458
import logging
from sqlalchemy import *
from sqlalchemy.engine import reflection
from alembic.migration import MigrationContext
from alembic.operations import Operations
from rhodecode.lib.dbmigrate.versions import _reset_base
from rhodecode.model import meta, init_model_encryption
log = logging.getLogger(__name__)
def _get_indexes_list(migrate_engine, table_name):
inspector = reflection.Inspector.from_engine(migrate_engine)
return inspector.get_indexes(table_name)
def upgrade(migrate_engine):
"""
Upgrade operations go here.
Don't create your own engine; bind migrate_engine to your metadata
"""
from rhodecode.model import db as db_5_1_0_0
# issue fixups
fixups(db_5_1_0_0, meta.Session)
def downgrade(migrate_engine):
pass
def fixups(models, _SESSION):
fix(db-migrate): enforce gc collection to optimize memory usage
r5504
chore: added excplicit db-migrate to update hooks for 5.X rel
r5458 for db_repo in _SESSION.query(models.Repository).all():
fix(db-migrate): enforce gc collection to optimize memory usage
r5504 try:
config = db_repo._config
config.set('extensions', 'largefiles', '')
chore: added excplicit db-migrate to update hooks for 5.X rel
r5458
fix(db-migrate): enforce gc collection to optimize memory usage
r5504 scm = db_repo.scm_instance(cache=False, config=config, vcs_full_cache=False)
chore: added excplicit db-migrate to update hooks for 5.X rel
r5458 if scm:
print(f'installing hook for repo: {db_repo}')
scm.install_hooks(force=True)
fix(db-migrate): enforce gc collection to optimize memory usage
r5504 del scm # force GC
del config
chore: added excplicit db-migrate to update hooks for 5.X rel
r5458 except Exception as e:
print(e)
print('continue...')