storyboard/storyboard/db/migration
Jeremy Stanley 27b208b8a6 For utf8mb4 shorten teams.name and users.email
Because the InnoDB default max key length is 767 bytes in MySQL 2.5
and 2.6, switch teams.name and users.email columns from
top_large_length (255 characters) to top_middle_length (100
characters). These are probably still sane lengths for these fields
and gets them below the 767/4=191 mark so that we can continue to
set them unique under utf8mb4.

Also, set the default database-wide character set to utf8mb4 so that
any new tables will inherit this.

While modifying a migration is generally taboo, this was the last to
merge and couldn't have applied successfully in production without
this modification anyway.

Change-Id: I6a571ac78f917866c14f541283e2bc0738ecf4c9
2018-03-27 20:21:07 +00:00
..
alembic_migrations For utf8mb4 shorten teams.name and users.email 2018-03-27 20:21:07 +00:00
README Add documentation on manually upgrading a StoryBoard instance 2017-10-11 22:06:45 +01:00
__init__.py Add SQLalchemy database model 2014-01-13 18:52:47 +04:00
alembic.ini Add SQLalchemy database model 2014-01-13 18:52:47 +04:00
cli.py switch from incubated gettextutils to oslo.i18n 2016-11-07 08:47:47 -05:00

README

# Copyright 2012 New Dream Network, LLC (DreamHost)
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

The migrations in the alembic_migrations/versions contain the changes needed
to migrate from older storyboard releases to newer versions. A migration occurs
by executing a script that details the changes needed to upgrade/downgrade
the database. The migration scripts are ordered so that multiple scripts
can run sequentially to update the database. The scripts are executed by
storyboard's migration wrapper which uses the Alembic library to manage the
migration.

This utility should be also used to load Project Groups and Projects form a .yaml
file description. The description sample is provided in etc/projects.yaml.
$ storyboard-db-manage --config-file /path/to/storyboard.conf \
    load_projects /path/to/projects.yaml


DEVELOPERS:
A database migration script is required when you submit a change to storyboard
that alters the database model definition.  The migration script is a special
python file that includes code to update/downgrade the database to match the
changes in the model definition. Alembic will execute these scripts in order to
provide a linear migration path between revision. The storyboard-db-manage
command can be used to generate migration template for you to complete.  The
operations in the template are those supported by the Alembic migration library.

$ storyboard-db-manage --config-file /path/to/storyboard.conf \
    revision -m "description of revision" --autogenerate

This generates a prepopulated template with the changes needed to match the
database state with the models.  You should inspect the autogenerated template
to ensure that the proper models have been altered.

In rare circumstances, you may want to start with an empty migration template
and manually author the changes necessary for an upgrade/downgrade.  You can
create a blank file via:

$ storyboard-db-manage --config-file /path/to/storyboard.conf \
    revision -m "description of revision"

The migration timeline should remain linear so that there is a clear path when
upgrading/downgrading.  To verify that the timeline does branch, you can run
this command:
$ storyboard-db-manage --config-file /path/to/storyboard.conf check_migration

If the migration path does branch, you can find the branch point via:
$ storyboard-db-manage --config-file /path/to/storyboard.conf history