##// END OF EJS Templates
First step in two-part process to rename directories to kallithea....
First step in two-part process to rename directories to kallithea. This first step is to change all references in the files where they refer to the old directory name.

File last commit:

r4186:7e5f8c12 kallithea-2.2.5-r...
r4186:7e5f8c12 kallithea-2.2.5-r...
Show More
006_version_1_4_0.py
177 lines | 7.1 KiB | text/x-python | PythonLexer
space fix
r2550 import logging
import datetime
from sqlalchemy import *
from sqlalchemy.exc import DatabaseError
from sqlalchemy.orm import relation, backref, class_mapper
from sqlalchemy.orm.session import Session
Step6a for migrations from 1.3.6...
r2765 from sqlalchemy.ext.declarative import declarative_base
space fix
r2550
Bradley M. Kuhn
First step in two-part process to rename directories to kallithea....
r4186 from kallithea.lib.dbmigrate.migrate import *
from kallithea.lib.dbmigrate.migrate.changeset import *
space fix
r2550
Bradley M. Kuhn
First step in two-part process to rename directories to kallithea....
r4186 from kallithea.model.meta import Base
from kallithea.model import meta
from kallithea.lib.dbmigrate.versions import _reset_base
space fix
r2550
log = logging.getLogger(__name__)
def upgrade(migrate_engine):
Step6a for migrations from 1.3.6...
r2765 """
Upgrade operations go here.
space fix
r2550 Don't create your own engine; bind migrate_engine to your metadata
"""
Step6a for migrations from 1.3.6...
r2765 #==========================================================================
# USEREMAILMAP
#==========================================================================
Bradley M. Kuhn
First step in two-part process to rename directories to kallithea....
r4186 from kallithea.lib.dbmigrate.schema.db_1_4_0 import UserEmailMap
Step6a for migrations from 1.3.6...
r2765 tbl = UserEmailMap.__table__
tbl.create()
#==========================================================================
# PULL REQUEST
#==========================================================================
Bradley M. Kuhn
First step in two-part process to rename directories to kallithea....
r4186 from kallithea.lib.dbmigrate.schema.db_1_4_0 import PullRequest
Step6a for migrations from 1.3.6...
r2765 tbl = PullRequest.__table__
tbl.create()
#==========================================================================
# PULL REQUEST REVIEWERS
#==========================================================================
Bradley M. Kuhn
First step in two-part process to rename directories to kallithea....
r4186 from kallithea.lib.dbmigrate.schema.db_1_4_0 import PullRequestReviewers
Step6a for migrations from 1.3.6...
r2765 tbl = PullRequestReviewers.__table__
tbl.create()
#==========================================================================
# CHANGESET STATUS
#==========================================================================
Bradley M. Kuhn
First step in two-part process to rename directories to kallithea....
r4186 from kallithea.lib.dbmigrate.schema.db_1_4_0 import ChangesetStatus
Step6a for migrations from 1.3.6...
r2765 tbl = ChangesetStatus.__table__
tbl.create()
Migration upgrades cache for lightweight dashboard...
r3148 _reset_base(migrate_engine)
Step6a for migrations from 1.3.6...
r2765
#==========================================================================
# USERS TABLE
#==========================================================================
Bradley M. Kuhn
First step in two-part process to rename directories to kallithea....
r4186 from kallithea.lib.dbmigrate.schema.db_1_3_0 import User
Step6a for migrations from 1.3.6...
r2765 tbl = User.__table__
# change column name -> firstname
col = User.__table__.columns.name
col.alter(index=Index('u_username_idx', 'username'))
col.alter(index=Index('u_email_idx', 'email'))
col.alter(name="firstname", table=tbl)
typos+docs.
r2769 # add inherit_default_permission column
More fixes to upgrade procedure,...
r2767 inherit_default_permissions = Column("inherit_default_permissions",
Boolean(), nullable=True, unique=None,
default=True)
inherit_default_permissions.create(table=tbl)
inherit_default_permissions.alter(nullable=False, default=True, table=tbl)
#==========================================================================
typos+docs.
r2769 # USERS GROUP TABLE
#==========================================================================
Bradley M. Kuhn
First step in two-part process to rename directories to kallithea....
r4186 from kallithea.lib.dbmigrate.schema.db_1_3_0 import UserGroup
Mads Kiilerich
further cleanup of UsersGroup...
r3417 tbl = UserGroup.__table__
typos+docs.
r2769 # add inherit_default_permission column
gr_inherit_default_permissions = Column(
"users_group_inherit_default_permissions",
Boolean(), nullable=True, unique=None,
default=True)
gr_inherit_default_permissions.create(table=tbl)
gr_inherit_default_permissions.alter(nullable=False, default=True, table=tbl)
#==========================================================================
Step6a for migrations from 1.3.6...
r2765 # REPOSITORIES
#==========================================================================
Bradley M. Kuhn
First step in two-part process to rename directories to kallithea....
r4186 from kallithea.lib.dbmigrate.schema.db_1_3_0 import Repository
Step6a for migrations from 1.3.6...
r2765 tbl = Repository.__table__
typos+docs.
r2769 # add enable locking column
Step6a for migrations from 1.3.6...
r2765 enable_locking = Column("enable_locking", Boolean(), nullable=True,
unique=None, default=False)
enable_locking.create(table=tbl)
enable_locking.alter(nullable=False, default=False, table=tbl)
typos+docs.
r2769 # add locked column
Step6a for migrations from 1.3.6...
r2765 _locked = Column("locked", String(255), nullable=True, unique=False,
default=None)
_locked.create(table=tbl)
typos+docs.
r2769 #add langing revision column
Step6a for migrations from 1.3.6...
r2765 landing_rev = Column("landing_revision", String(255), nullable=True,
unique=False, default='tip')
landing_rev.create(table=tbl)
landing_rev.alter(nullable=False, default='tip', table=tbl)
#==========================================================================
# GROUPS
#==========================================================================
Bradley M. Kuhn
First step in two-part process to rename directories to kallithea....
r4186 from kallithea.lib.dbmigrate.schema.db_1_3_0 import RepoGroup
Step6a for migrations from 1.3.6...
r2765 tbl = RepoGroup.__table__
typos+docs.
r2769
# add enable locking column
Step6a for migrations from 1.3.6...
r2765 enable_locking = Column("enable_locking", Boolean(), nullable=True,
unique=None, default=False)
enable_locking.create(table=tbl)
enable_locking.alter(nullable=False, default=False)
#==========================================================================
# CACHE INVALIDATION
#==========================================================================
Bradley M. Kuhn
First step in two-part process to rename directories to kallithea....
r4186 from kallithea.lib.dbmigrate.schema.db_1_3_0 import CacheInvalidation
Step6a for migrations from 1.3.6...
r2765 tbl = CacheInvalidation.__table__
typos+docs.
r2769 # add INDEX for cache keys
Step6a for migrations from 1.3.6...
r2765 col = CacheInvalidation.__table__.columns.cache_key
col.alter(index=Index('key_idx', 'cache_key'))
#==========================================================================
# NOTIFICATION
#==========================================================================
Bradley M. Kuhn
First step in two-part process to rename directories to kallithea....
r4186 from kallithea.lib.dbmigrate.schema.db_1_3_0 import Notification
Step6a for migrations from 1.3.6...
r2765 tbl = Notification.__table__
typos+docs.
r2769 # add index for notification type
Step6a for migrations from 1.3.6...
r2765 col = Notification.__table__.columns.type
col.alter(index=Index('notification_type_idx', 'type'),)
#==========================================================================
# CHANGESET_COMMENTS
#==========================================================================
Bradley M. Kuhn
First step in two-part process to rename directories to kallithea....
r4186 from kallithea.lib.dbmigrate.schema.db_1_3_0 import ChangesetComment
Step6a for migrations from 1.3.6...
r2765
tbl = ChangesetComment.__table__
typos+docs.
r2769 col = ChangesetComment.__table__.columns.revision
Step6a for migrations from 1.3.6...
r2765
typos+docs.
r2769 # add index for revisions
Step6a for migrations from 1.3.6...
r2765 col.alter(index=Index('cc_revision_idx', 'revision'),)
typos+docs.
r2769 # add hl_lines column
Step6a for migrations from 1.3.6...
r2765 hl_lines = Column('hl_lines', Unicode(512), nullable=True)
hl_lines.create(table=tbl)
typos+docs.
r2769 # add created_on column
Step6a for migrations from 1.3.6...
r2765 created_on = Column('created_on', DateTime(timezone=False), nullable=True,
default=datetime.datetime.now)
created_on.create(table=tbl)
created_on.alter(nullable=False, default=datetime.datetime.now)
typos+docs.
r2769
Step6a for migrations from 1.3.6...
r2765 modified_at = Column('modified_at', DateTime(timezone=False), nullable=False,
default=datetime.datetime.now)
modified_at.alter(type=DateTime(timezone=False), table=tbl)
typos+docs.
r2769 # add FK to pull_request
Step6a for migrations from 1.3.6...
r2765 pull_request_id = Column("pull_request_id", Integer(),
ForeignKey('pull_requests.pull_request_id'),
nullable=True)
pull_request_id.create(table=tbl)
Migration upgrades cache for lightweight dashboard...
r3148 _reset_base(migrate_engine)
space fix
r2550
def downgrade(migrate_engine):
meta = MetaData()
meta.bind = migrate_engine