Drop support for SQL Schema Downgrades

SQL Schema Downgrades are no longer supported. This commit removes
downgrade function from octavia-db-manage.

Related cross-project spec: https://review.openstack.org/152337
Partial-Bug: #1434103

Change-Id: I0304d19ebb2de3a596c9f62825e664267ad60dd8
Sergey Belous 7 years ago
parent 3bf6ccb736
commit b44619e55a

@ -100,19 +100,6 @@ effort to allow for Neutron LBaaS API deprecation of URIs. The rationale is
that Neutron LBaaS API users should have the ability to transition from one
version to the next easily.
Upgrade and downgrade migrations will be supported
Whenever large operators conduct upgrades it is important to have a backup
plan in the form of downgrades. While upgrade migrations are commonplace,
often, downgrade migrations are ignored. Octavia will support migrations that
allow for seamless version to version upgrades/downgrades within the scope of a
major version.
For example, assume that an operator is currently hosting version 1.0 of
Octavia and wants to upgrade to Octavia version 1.1. A database migration will
consist of an upgrade migration and a downgrade migration that do not fail due
to foreign key constraints or other typical migration issues.
Scalability and resilience are as important as functionality
Octavia is meant to be an *operator scale* load balancer. As such, it's usually

@ -11,6 +11,3 @@ To run migrations you must first be in the octavia/db/migration directory.
To migrate to the most current version run:
$ alembic upgrade head
To downgrade one migration run:
$ alembic downgrade -1

@ -16,7 +16,3 @@ ${imports if imports else ""}
def upgrade():
${upgrades if upgrades else "pass"}
def downgrade():
${downgrades if downgrades else "pass"}

@ -36,19 +36,36 @@ def do_check_migration(config, _cmd):
do_alembic_command(config, 'branches')
def do_upgrade_downgrade(config, cmd):
def add_alembic_subparser(sub, cmd):
return sub.add_parser(cmd, help=getattr(alembic_cmd, cmd).__doc__)
def do_upgrade(config, cmd):
if not CONF.command.revision and not CONF.command.delta:
raise SystemExit('You must provide a revision or relative delta')
revision = CONF.command.revision
revision = CONF.command.revision or ''
if '-' in revision:
raise SystemExit(_('Negative relative revision (downgrade) not '
if CONF.command.delta:
sign = '+' if CONF.command.name == 'upgrade' else '-'
revision = sign + str(CONF.command.delta)
delta = CONF.command.delta
if delta:
if '+' in revision:
raise SystemExit(_('Use either --delta or relative revision, '
'not both'))
if delta < 0:
raise SystemExit(_('Negative delta (downgrade) not supported'))
revision = '%s+%d' % (revision, delta)
do_alembic_command(config, cmd, revision, sql=CONF.command.sql)
def no_downgrade(config, cmd):
raise SystemExit(_("Downgrade no longer supported"))
def do_stamp(config, cmd):
do_alembic_command(config, cmd,
@ -64,25 +81,30 @@ def do_revision(config, cmd):
def add_command_parsers(subparsers):
for name in ['current', 'history', 'branches']:
parser = subparsers.add_parser(name)
parser = add_alembic_subparser(subparsers, name)
parser = subparsers.add_parser('check_migration')
help_text = (getattr(alembic_cmd, 'branches').__doc__ +
' and validate head file')
parser = subparsers.add_parser('check_migration', help=help_text)
for name in ['upgrade', 'downgrade']:
parser = subparsers.add_parser(name)
parser.add_argument('--delta', type=int)
parser.add_argument('--sql', action='store_true')
parser.add_argument('revision', nargs='?')
parser = add_alembic_subparser(subparsers, 'upgrade')
parser.add_argument('--delta', type=int)
parser.add_argument('--sql', action='store_true')
parser.add_argument('revision', nargs='?')
parser = subparsers.add_parser('downgrade', help="(No longer supported)")
parser.add_argument('None', nargs='?', help="Downgrade not supported")
parser = subparsers.add_parser('stamp')
parser = add_alembic_subparser(subparsers, 'stamp')
parser.add_argument('--sql', action='store_true')
parser = subparsers.add_parser('revision')
parser = add_alembic_subparser(subparsers, 'revision')
parser.add_argument('-m', '--message')
parser.add_argument('--autogenerate', action='store_true')
parser.add_argument('--sql', action='store_true')