Changeset - 7562f46b1e90
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 13 years ago 2012-09-01 20:30:19
marcin@python-works.com
More fixes to upgrade procedure,
- fix missing section on hook
- fixed missing inherit_default_permission column
2 files changed with 12 insertions and 0 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/db_manage.py
Show inline comments
 
@@ -142,96 +142,97 @@ class DbManage(object):
 
            """
 
            Those steps follow schema versions so for example schema
 
            for example schema with seq 002 == step_2 and so on.
 
            """
 

	
 
            def __init__(self, klass):
 
                self.klass = klass
 

	
 
            def step_0(self):
 
                # step 0 is the schema upgrade, and than follow proper upgrades
 
                print ('attempting to do database upgrade to version %s' \
 
                                % __dbversion__)
 
                api.upgrade(db_uri, repository_path, __dbversion__)
 
                print ('Schema upgrade completed')
 

	
 
            def step_1(self):
 
                pass
 

	
 
            def step_2(self):
 
                print ('Patching repo paths for newer version of RhodeCode')
 
                self.klass.fix_repo_paths()
 

	
 
                print ('Patching default user of RhodeCode')
 
                self.klass.fix_default_user()
 

	
 
                log.info('Changing ui settings')
 
                self.klass.create_ui_settings()
 

	
 
            def step_3(self):
 
                print ('Adding additional settings into RhodeCode db')
 
                self.klass.fix_settings()
 
                print ('Adding ldap defaults')
 
                self.klass.create_ldap_options(skip_existing=True)
 

	
 
            def step_4(self):
 
                print ('create permissions and fix groups')
 
                self.klass.create_permissions()
 
                self.klass.fixup_groups()
 

	
 
            def step_5(self):
 
                pass
 

	
 
            def step_6(self):
 
                print ('re-checking permissions')
 
                self.klass.create_permissions()
 

	
 
                print ('installing new hooks')
 
                hooks4 = RhodeCodeUi()
 
                hooks4.ui_section = 'hooks'
 
                hooks4.ui_key = RhodeCodeUi.HOOK_PRE_PUSH
 
                hooks4.ui_value = 'python:rhodecode.lib.hooks.pre_push'
 
                Session().add(hooks4)
 

	
 
                hooks6 = RhodeCodeUi()
 
                hooks6.ui_section = 'hooks'
 
                hooks6.ui_key = RhodeCodeUi.HOOK_PRE_PULL
 
                hooks6.ui_value = 'python:rhodecode.lib.hooks.pre_pull'
 
                Session().add(hooks6)
 

	
 
                print ('installing hgsubversion option')
 
                # enable hgsubversion disabled by default
 
                hgsubversion = RhodeCodeUi()
 
                hgsubversion.ui_section = 'extensions'
 
                hgsubversion.ui_key = 'hgsubversion'
 
                hgsubversion.ui_value = ''
 
                hgsubversion.ui_active = False
 
                Session().add(hgsubversion)
 

	
 
                print ('installing hg git option')
 
                # enable hggit disabled by default
 
                hggit = RhodeCodeUi()
 
                hggit.ui_section = 'extensions'
 
                hggit.ui_key = 'hggit'
 
                hggit.ui_value = ''
 
                hggit.ui_active = False
 
                Session().add(hggit)
 

	
 
                print ('re-check default permissions')
 
                self.klass.populate_default_permissions()
 

	
 
        upgrade_steps = [0] + range(curr_version + 1, __dbversion__ + 1)
 

	
 
        # CALL THE PROPER ORDER OF STEPS TO PERFORM FULL UPGRADE
 
        for step in upgrade_steps:
 
            print ('performing upgrade step %s' % step)
 
            getattr(UpgradeSteps(self), 'step_%s' % step)()
 
            self.sa.commit()
 

	
 
    def fix_repo_paths(self):
 
        """
 
        Fixes a old rhodecode version path into new one without a '*'
 
        """
 

	
 
        paths = self.sa.query(RhodeCodeUi)\
 
                .filter(RhodeCodeUi.ui_key == '/')\
 
                .scalar()
 

	
rhodecode/lib/dbmigrate/versions/006_version_1_4_0.py
Show inline comments
 
@@ -30,96 +30,107 @@ def upgrade(migrate_engine):
 
    tbl.create()
 
    #==========================================================================
 
    # PULL REQUEST
 
    #==========================================================================
 
    from rhodecode.lib.dbmigrate.schema.db_1_4_0 import PullRequest
 
    tbl = PullRequest.__table__
 
    tbl.create()
 

	
 
    #==========================================================================
 
    # PULL REQUEST REVIEWERS
 
    #==========================================================================
 
    from rhodecode.lib.dbmigrate.schema.db_1_4_0 import PullRequestReviewers
 
    tbl = PullRequestReviewers.__table__
 
    tbl.create()
 

	
 
    #==========================================================================
 
    # CHANGESET STATUS
 
    #==========================================================================
 
    from rhodecode.lib.dbmigrate.schema.db_1_4_0 import ChangesetStatus
 
    tbl = ChangesetStatus.__table__
 
    tbl.create()
 

	
 
    ## RESET COMPLETLY THE metadata for sqlalchemy to use the 1_3_0 Base 
 
    Base = declarative_base()
 
    Base.metadata.clear()
 
    Base.metadata = MetaData()
 
    Base.metadata.bind = migrate_engine
 
    meta.Base = Base
 

	
 
    #==========================================================================
 
    # USERS TABLE
 
    #==========================================================================
 
    from rhodecode.lib.dbmigrate.schema.db_1_3_0 import User
 
    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)
 

	
 
    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)
 

	
 
    #==========================================================================
 
    # GROUPS TABLE
 
    #==========================================================================
 
    from rhodecode.lib.dbmigrate.schema.db_1_3_0 import RepoGroup
 
    tbl = RepoGroup.__table__
 
    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)
 

	
 
    #==========================================================================
 
    # REPOSITORIES
 
    #==========================================================================
 
    from rhodecode.lib.dbmigrate.schema.db_1_3_0 import Repository
 
    tbl = Repository.__table__
 

	
 
    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)
 

	
 
    _locked = Column("locked", String(255), nullable=True, unique=False,
 
                     default=None)
 
    _locked.create(table=tbl)
 

	
 
    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
 
    #==========================================================================
 
    from rhodecode.lib.dbmigrate.schema.db_1_3_0 import RepoGroup
 
    tbl = RepoGroup.__table__
 
    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
 
    #==========================================================================
 
    from rhodecode.lib.dbmigrate.schema.db_1_3_0 import CacheInvalidation
 
    tbl = CacheInvalidation.__table__
 

	
 
    # change column name -> firstname
 
    col = CacheInvalidation.__table__.columns.cache_key
 
    col.alter(index=Index('key_idx', 'cache_key'))
 

	
 
    #==========================================================================
 
    # NOTIFICATION
 
    #==========================================================================
 
    from rhodecode.lib.dbmigrate.schema.db_1_3_0 import Notification
 
    tbl = Notification.__table__
 

	
 
    # change column name -> firstname
 
    col = Notification.__table__.columns.type
 
    col.alter(index=Index('notification_type_idx', 'type'),)
0 comments (0 inline, 0 general)