Compare Revisions
Showing 13 commits
Merge Ancestor: 96779dba8b01
13 kwi 951248761e43
9 years ago
4 Extinct Draft default
12 kwi bdaecf79a6fb
9 years ago
11 kwi 1327582c9af5
9 years ago
2 Extinct Draft default
10 kwi 08b57807cb24
9 years ago
Extinct Draft default
9 kwi 01bf1b9a2c37
9 years ago
8 kwi 16c36d73e993
9 years ago
1 Extinct Draft default
7 kwi 28acc1d56a8a
9 years ago
Extinct Draft default
6 kwi 0bb267c2d5ab
9 years ago
Extinct Draft default
5 kwi bd333df2742f
9 years ago
Extinct Draft default
4 kwi a7ec1039974f
9 years ago
Extinct Draft default
3 kwi 805a27107d99
9 years ago
2 kwi e4b6c86aa5e2
9 years ago
1 kwi ebd68713988b
9 years ago
6 Extinct Draft default
14 files changed with 247 insertions and 220 deletions:
README.rst
Show inline comments
 
@@ -165,10 +165,11 @@ You can also build the documentation loc
 
Migrating from RhodeCode
 
------------------------
 

	
 
Previous versions of Kallithea supports migrating from an existing
 
RhodeCode installation. To migrate, install Kallithea 0.3 and follow
 
the instructions in the 0.3 README to perform a one-time conversion of
 
the RhodeCode database, before upgrading to this Kallithea version.
 
Kallithea 0.3.x and earlier supports migrating from an existing RhodeCode
 
installation. To migrate, install the latest Kallithea 0.3.x and follow
 
the instructions in the 0.3.x README to perform a one-time conversion of
 
the database from RhodeCode to Kallithea, before upgrading to this
 
version of Kallithea.
 

	
 

	
 
.. _virtualenv: http://pypi.python.org/pypi/virtualenv
docs/dbmigrations.rst
Show inline comments
 
deleted file
docs/dev/dbmigrations.rst
Show inline comments
 
@@ -4,10 +4,10 @@ Database schema changes
 

	
 
Kallithea uses Alembic for :ref:`database upgrades and downgrades <dbmigrations>`.
 

	
 
If you are developing a Kallithea feature that requires database changes,
 
you should make a matching Alembic database migration script:
 
If you are developing a Kallithea feature that requires database schema
 
changes, you should make a matching Alembic database migration script:
 

	
 
1. Make your code changes (including database model changes)
 
1. Make your code changes (including database schema changes in ``db.py``).
 

	
 
2. Using a database that has *not* been upgraded, you can auto-generate
 
   a draft Alembic script that will upgrade a database to match the code::
 
@@ -19,10 +19,14 @@ 3. Edit the script to clean it up and fi
 

	
 
4. Run ``alembic upgrade`` to apply changes to the database.
 

	
 
The Alembic migration script should be committed in the same revision as
 
the database schema (``db.py``) changes.
 

	
 
Assuming your changes are eventually included in the Kallithea mainline,
 
the script's ``down_revision`` ("Revises") will at that point need to be
 
updated to match the linear mainline history.
 

	
 
See the `Alembic documentation`__ for more information.
 
See the `Alembic documentation`__ for more information, in particular
 
the tutorial and the section about auto-generating migration scripts.
 

	
 
.. __: http://alembic.readthedocs.org/
 
.. __: https://alembic.readthedocs.io/en/latest/
docs/index.rst
Show inline comments
 
@@ -23,7 +23,7 @@ Kallithea Documentation
 
   installation_iis
 
   setup
 
   installation_puppet
 
   dbmigrations
 
   upgrade
 

	
 
**Usage**
 

	
docs/installation.rst
Show inline comments
 
@@ -45,9 +45,6 @@ repository, follow the instructions belo
 

	
 
You can now proceed to :ref:`setup`.
 

	
 
To upgrade, simply update the repository with ``hg pull -u`` and restart the
 
server.
 

	
 
.. _installation-virtualenv:
 

	
 

	
 
@@ -123,75 +120,5 @@ To install as a regular user in ``~/.loc
 
You can now proceed to :ref:`setup`.
 

	
 

	
 
Upgrading Kallithea from Python Package Index (PyPI)
 
----------------------------------------------------
 

	
 
.. note::
 
   It is strongly recommended that you **always** perform a database and
 
   configuration backup before doing an upgrade.
 

	
 
   These directions will use '{version}' to note that this is the version of
 
   Kallithea that these files were used with.  If backing up your Kallithea
 
   instance from version 0.1 to 0.2, the ``my.ini`` file could be
 
   backed up to ``my.ini.0-1``.
 

	
 
If using a SQLite database, stop the Kallithea process/daemon/service, and
 
then make a copy of the database file::
 

	
 
 service kallithea stop
 
 cp kallithea.db kallithea.db.{version}
 

	
 
Back up your configuration file::
 

	
 
 cp my.ini my.ini.{version}
 

	
 
Ensure that you are using the Python virtual environment that you originally
 
installed Kallithea in by running::
 

	
 
 pip freeze
 

	
 
This will list all packages installed in the current environment.  If
 
Kallithea isn't listed, activate the correct virtual environment::
 

	
 
 source /srv/kallithea/venv/bin/activate
 

	
 
Once you have verified the environment you can upgrade Kallithea with::
 

	
 
 pip install --upgrade kallithea
 

	
 
Then run the following command from the installation directory::
 

	
 
 paster make-config Kallithea my.ini
 

	
 
This will display any changes made by the new version of Kallithea to your
 
current configuration. It will try to perform an automerge. It is recommended
 
that you recheck the content after the automerge.
 

	
 
.. note::
 
   Please always make sure your .ini files are up to date. Errors can
 
   often be caused by missing parameters added in new versions.
 

	
 
It is also recommended that you rebuild the whoosh index after upgrading since
 
the new whoosh version could introduce some incompatible index changes. Please
 
read the changelog to see if there were any changes to whoosh.
 

	
 
You may find it helpful to clear out your log file so that new errors are
 
readily apparent::
 

	
 
 echo > kallithea.log
 

	
 
Once that is complete, you may now start your upgraded Kallithea Instance::
 

	
 
 service kallithea start
 

	
 
Or::
 

	
 
 paster serve /srv/kallithea/my.ini
 

	
 
.. note::
 
   If you're using Celery, make sure you restart all instances of it after
 
   upgrade.
 

	
 

	
 
.. _virtualenv: http://pypi.python.org/pypi/virtualenv
 
.. _pylons: http://www.pylonsproject.org/
docs/installation_win.rst
Show inline comments
 
@@ -219,23 +219,3 @@ What this guide does not cover:
 
- Using Apache. You can investigate here:
 

	
 
  - https://groups.google.com/group/rhodecode/msg/c433074e813ffdc4
 

	
 

	
 
Upgrading
 
---------
 

	
 
Stop running Kallithea
 
Open a CommandPrompt like in Step 7 (cd to C:\Kallithea\Env\Scripts and activate) and type::
 

	
 
  pip install kallithea --upgrade
 
  cd \Kallithea\Bin
 

	
 
Backup your production.ini file now.
 

	
 
Then run::
 

	
 
  paster make-config Kallithea production.ini
 

	
 
Look for changes and update your production.ini accordingly.
 

	
 
More details can be found in `<upgrade.html>`_.
docs/installation_win_old.rst
Show inline comments
 
@@ -260,21 +260,3 @@ What this Guide does not cover:
 
- Using Apache. You can investigate here:
 

	
 
  - https://groups.google.com/group/rhodecode/msg/c433074e813ffdc4
 

	
 

	
 
Upgrading
 
---------
 

	
 
Stop running Kallithea
 
Open a CommandPrompt like in Step7 (VS2008 path + activate) and type::
 

	
 
 easy_install -U kallithea
 
 cd \Kallithea\Bin
 

	
 
{ backup your production.ini file now} ::
 

	
 
 paster make-config Kallithea production.ini
 

	
 
(check changes and update your production.ini accordingly)
 

	
 
Full steps in http://packages.python.org/Kallithea/upgrade.html
docs/upgrade.rst
Show inline comments
 
new file 100644
 
.. _upgrade:
 

	
 
===================
 
Upgrading Kallithea
 
===================
 

	
 
The following describes the upgrade steps needed, independently of the
 
Kallithea installation manner.
 

	
 

	
 
1. Stop the Kallithea web application
 
-------------------------------------
 

	
 
This step depends entirely on the web server software used to serve
 
Kallithea, but in any case, Kallithea should not be running during
 
the upgrade.
 

	
 

	
 
2. Create a backup of both database and configuration
 
-----------------------------------------------------
 

	
 
You are of course strongly recommended to make backups regularly, but it
 
is **especially** important to make a full database and configuration
 
backup before performing a Kallithea upgrade.
 

	
 

	
 
Back up your configuration
 
~~~~~~~~~~~~~~~~~~~~~~~~~~
 

	
 
Make a copy of your Kallithea configuration (``.ini``) file.
 

	
 

	
 
Back up your database
 
~~~~~~~~~~~~~~~~~~~~~
 

	
 
If using SQLite, simply make a copy of the Kallithea database (``.db``)
 
file.
 

	
 
If using PostgreSQL, please consult the documentation for the ``pg_dump``
 
utility.
 

	
 
If using MySQL, please consult the documentation for the ``mysqldump``
 
utility.
 

	
 
Look for ``sqlalchemy.db1.url`` in your configuration file to determine
 
database type, settings, location, etc.
 

	
 

	
 
3. Activate the Kallithea virtual environment (if any)
 
------------------------------------------------------
 

	
 
Ensure that you are using the Python environment that you originally
 
installed Kallithea in by running::
 

	
 
    pip freeze
 

	
 
This will list all packages installed in the current environment. If
 
Kallithea isn't listed, activate the correct virtual environment.
 
See the appropriate installation page for details.
 

	
 

	
 
4. Install new version of Kallithea
 
-----------------------------------
 

	
 
Please refer to the instructions for the installation method you
 
originally used to install Kallithea.
 

	
 
If you originally installed using pip, it is as simple as::
 

	
 
    pip install --upgrade kallithea
 

	
 
If you originally installed from version control, it is as simple as::
 

	
 
    cd my-kallithea-clone
 
    hg pull -u
 
    pip install -e .
 

	
 

	
 
5. Upgrade your configuration
 
-----------------------------
 

	
 
Run the following command to upgrade your configuration (``.ini``) file::
 

	
 
    paster make-config Kallithea my.ini
 

	
 
This will display any changes made by the new version of Kallithea to your
 
current configuration, and attempt an automatic merge. It is recommended
 
that you recheck the content after the merge.
 

	
 
.. note::
 
    Please always make sure your ``.ini`` files are up to date. Errors
 
    can often be caused by missing parameters added in new versions.
 

	
 

	
 
.. _dbmigrations:
 

	
 
6. Upgrade your database
 
------------------------
 

	
 
.. note::
 
    If you are *downgrading* Kallithea, you should perform the database
 
    migration step *before* installing the older version. (That is,
 
    always perform migrations using the most recent of the two versions
 
    you're migrating between.)
 

	
 
First, run the following command to see your current database version::
 

	
 
    alembic -c my.ini current
 

	
 
Typical output will be something like "9358dc3d6828 (head)", which is
 
the current Alembic database "revision ID". Write down the entire output
 
for troubleshooting purposes (in case anything goes wrong), or in case
 
you later want to revert to this Kallithea version.
 

	
 
The output will be empty if you're upgrading from Kallithea 0.3.x or
 
older. That's expected. If you get an error that the config file was not
 
found or has no ``[alembic]`` section, see the next section.
 

	
 
Next, if you are performing an *upgrade*: Run the following command to
 
upgrade your database to the current Kallithea version::
 

	
 
    alembic -c my.ini upgrade head
 

	
 
If you are performing a *downgrade*: Determine the target Alembic
 
"revision ID" (which, as noted above, you should have written down
 
before upgrading). Then run the following command to downgrade your
 
database to a given version (example shown here will downgrade to
 
Kallithea 0.4)::
 

	
 
    alembic -c my.ini downgrade 9358dc3d6828
 

	
 
Alembic will show the necessary migrations (if any) as it executes
 
them. If no "ERROR" is displayed, the command was successful.
 

	
 
Should an error occur, the database may be "stranded" half-way
 
through the migration, and you should restore it from backup.
 

	
 

	
 
Enabling old Kallithea config files for Alembic use
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

	
 
Kallithea configuration files created before the introduction of Alembic
 
(i.e. predating Kallithea 0.4) needs to be updated for use with Alembic.
 
Without this, Alembic will fail with an error along the following lines::
 

	
 
    FAILED: No config file 'my.ini' found, or file has no '[alembic]' section
 

	
 
If Alembic complains specifically about a missing ``alembic.ini``, it is
 
likely because you did not specify a config file using the ``-c`` option.
 
On the other hand, if the mentioned config file actually exists, you
 
need to append the following lines to it::
 

	
 
    [alembic]
 
    script_location = kallithea:alembic
 

	
 
    [logger_alembic]
 
    level = INFO
 
    handlers =
 
    qualname = alembic
 

	
 
Next, find the existing ``loggers.keys`` entry in the file and append the
 
item ``alembic`` to it, like this::
 

	
 
    [loggers]
 
    keys = root, routes, kallithea, sqlalchemy, beaker, templates, whoosh_indexer, alembic
 

	
 
Your config file should now work with Alembic.
 

	
 

	
 
7. Rebuild the Whoosh full-text index
 
-------------------------------------
 

	
 
It is recommended that you rebuild the Whoosh index after upgrading since
 
new Whoosh versions can introduce incompatible index changes.
 

	
 

	
 
8. Start the Kallithea web application
 
--------------------------------------
 

	
 
This step once again depends entirely on the web server software used to
 
serve Kallithea.
 

	
 
Before starting the new version of Kallithea, you may find it helpful to
 
clear out your log file so that new errors are readily apparent.
 

	
 
.. note::
 
    If you're using Celery, make sure you restart all instances of it after
 
    upgrade.
 

	
 

	
 
.. _virtualenv: http://pypi.python.org/pypi/virtualenv
kallithea/alembic/env.py
Show inline comments
 
from __future__ import with_statement
 
# Alembic environment (configuration), based on file generated using
 
# "alembic init" and modified for Kallithea.
 
#
 
# Portions copyright (C) 2009-2016 by Michael Bayer.
 

	
 
from logging.config import fileConfig
 

	
 
from alembic import context
 
from sqlalchemy import engine_from_config, pool
 
from logging.config import fileConfig
 

	
 

	
 
# this is the Alembic Config object, which provides
 
# access to the values within the .ini file in use.
 
config = context.config
 

	
 
# Setup Python loggers based on the config file. If we're being invoked
 
# programatically, config_file_name is not set, and loggers are presumed
 
# to already have been configured.
 
# Setup Python loggers based on the config file provided to the alembic
 
# command. If we're being invoked via the Alembic API (presumably for
 
# stamping during "paster setup-db"), config_file_name is not available,
 
# and loggers are presumed to already have been configured.
 
if config.config_file_name:
 
    fileConfig(config.config_file_name)
 

	
 
# add your model's MetaData object here
 
# for 'autogenerate' support
 
# Support autogeneration of migration scripts based on "diff" between
 
# current database schema and kallithea.model.db schema.
 
from kallithea.model import db
 
target_metadata = db.Base.metadata
 

	
 
@@ -77,6 +84,7 @@ def run_migrations_online():
 
        with context.begin_transaction():
 
            context.run_migrations()
 

	
 

	
 
if context.is_offline_mode():
 
    run_migrations_offline()
 
else:
kallithea/alembic/script.py.mako
Show inline comments
 
## Template for creating new Alembic migration scripts, based on file
 
## generated using "alembic init" and modified for Kallithea.
 
##
 
## Portions copyright (C) 2009-2016 by Michael Bayer.
 
"""${message}
 

	
 
Revision ID: ${up_revision}
 
@@ -6,7 +10,8 @@ Create Date: ${create_date}
 

	
 
"""
 

	
 
# revision identifiers, used by Alembic.
 
# The following opaque hexadecimal identifiers ("revisions") are used
 
# by Alembic to track this migration script and its relations to others.
 
revision = ${repr(up_revision)}
 
down_revision = ${repr(down_revision)}
 
branch_labels = ${repr(branch_labels)}
kallithea/alembic/versions/9358dc3d6828_drop_sqlalchemy_migrate_support.py
Show inline comments
 
@@ -6,7 +6,8 @@ Create Date: 2016-03-01 15:21:30.896585
 

	
 
"""
 

	
 
# revision identifiers, used by Alembic.
 
# The following opaque hexadecimal identifiers ("revisions") are used
 
# by Alembic to track this migration script and its relations to others.
 
revision = '9358dc3d6828'
 
down_revision = None
 
branch_labels = None
kallithea/lib/db_manage.py
Show inline comments
 
@@ -27,11 +27,11 @@ Original author and date, and relevant c
 
"""
 

	
 
import os
 
import os.path
 
import sys
 
import time
 
import uuid
 
import logging
 
from os.path import dirname as dn, join as jn
 

	
 
import alembic.config
 
import alembic.command
 
@@ -108,11 +108,14 @@ class DbManage(object):
 
        Base.metadata.create_all(checkfirst=checkfirst)
 

	
 
        # Create an Alembic configuration and generate the version table,
 
        # "stamping" it with the most recent rev.
 
        # "stamping" it with the most recent Alembic migration revision, to
 
        # tell Alembic that all the schema upgrades are already in effect.
 
        alembic_cfg = alembic.config.Config()
 
        alembic_cfg.set_main_option('script_location', 'kallithea:alembic')
 
        alembic_cfg.set_main_option('sqlalchemy.url', self.dburi)
 
        # TODO: handle multi-head scenarios using something like alembic.command.heads(alembic_cfg)
 
        # This command will give an error in an Alembic multi-head scenario,
 
        # but in practice, such a scenario should not come up during database
 
        # creation, even during development.
 
        alembic.command.stamp(alembic_cfg, 'head')
 

	
 
        log.info('Created tables for %s', self.dbname)
kallithea/lib/dbmigrate.py
Show inline comments
 
new file 100644
 
from paste.script.command import Command
 

	
 
class UpgradeDb(Command):
 
    hidden = True
 

	
 
    def run(self, args):
 
        raise SystemExit(
 
            'The "paster upgrade-db" command has been removed; please see the docs:\n'
 
            '    https://kallithea.readthedocs.io/en/latest/upgrade.html'
 
        )
setup.py
Show inline comments
 
@@ -35,7 +35,7 @@ callback = lambda V: ('.'.join(map(str, 
 
is_windows = __platform__ in ['Windows']
 

	
 
requirements = [
 
    "alembic>=0.8.0,<0.9a0",
 
    "alembic>=0.8.0,<0.9",
 
    "waitress==0.8.8",
 
    "webob>=1.0.8,<=1.1.1",
 
    "webtest==1.4.3",
 
@@ -181,6 +181,7 @@ setup(
 
    cache-keys=kallithea.lib.paster_commands.cache_keys:Command
 
    ishell=kallithea.lib.paster_commands.ishell:Command
 
    make-index=kallithea.lib.paster_commands.make_index:Command
 
    upgrade-db=kallithea.lib.dbmigrate:UpgradeDb
 
    celeryd=kallithea.lib.celerypylons.commands:CeleryDaemonCommand
 
    install-iis=kallithea.lib.paster_commands.install_iis:Command
 
    """,