##// END OF EJS Templates
deps: bumped venusian==3.1.0 for python 3.12 compat
deps: bumped venusian==3.1.0 for python 3.12 compat

File last commit:

r5042:4c5af799 default
r5622:5bcb0167 default
Show More
096_version_4_17_0.py
55 lines | 1.6 KiB | text/x-python | PythonLexer
dbmigrate: python3 changes...
r5042
repository-groups: use lazy loaded admin dashboard
r3623
import logging
from alembic.migration import MigrationContext
from alembic.operations import Operations
from sqlalchemy import String, Column
from sqlalchemy.sql import text
from rhodecode.lib.dbmigrate.versions import _reset_base
migration: fix unicode problem on 4.17.0 migration
r3677 from rhodecode.lib.utils2 import safe_str
repository-groups: use lazy loaded admin dashboard
r3623 from rhodecode.model import meta, init_model_encryption
from rhodecode.model.db import RepoGroup
log = logging.getLogger(__name__)
def upgrade(migrate_engine):
"""
Upgrade operations go here.
Don't create your own engine; bind migrate_engine to your metadata
"""
_reset_base(migrate_engine)
from rhodecode.lib.dbmigrate.schema import db_4_16_0_2
init_model_encryption(db_4_16_0_2)
context = MigrationContext.configure(migrate_engine.connect())
op = Operations(context)
repo_group = db_4_16_0_2.RepoGroup.__table__
feat: changed last change of repo group to be commit of a latest repository.
r3689
repository-groups: use lazy loaded admin dashboard
r3623 with op.batch_alter_table(repo_group.name) as batch_op:
batch_op.add_column(
Column("repo_group_name_hash", String(1024), nullable=True, unique=False))
_generate_repo_group_name_hashes(db_4_16_0_2, op, meta.Session)
def downgrade(migrate_engine):
pass
def _generate_repo_group_name_hashes(models, op, session):
repo_groups = models.RepoGroup.get_all()
for repo_group in repo_groups:
migration: fix unicode problem on 4.17.0 migration
r3677 print(safe_str(repo_group.group_name))
repository-groups: use lazy loaded admin dashboard
r3623 hash_ = RepoGroup.hash_repo_group_name(repo_group.group_name)
params = {'hash': hash_, 'id': repo_group.group_id}
query = text(
'UPDATE groups SET repo_group_name_hash = :hash'
' WHERE group_id = :id').bindparams(**params)
op.execute(query)
session().commit()