Merge pull request #2483 from charltonaustin/phase_four_config
feat(data): remove subdir
This commit is contained in:
commit
f1d6a7284d
2 changed files with 61 additions and 3 deletions
|
@ -10,7 +10,6 @@ up_mysql() {
|
|||
# Run a SQL database on port 3306 inside of Docker.
|
||||
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -d mysql
|
||||
|
||||
# Sleep for 25s to get MySQL get started.
|
||||
echo 'Sleeping for 25...'
|
||||
sleep 25
|
||||
|
||||
|
@ -27,7 +26,6 @@ up_mariadb() {
|
|||
# Run a SQL database on port 3306 inside of Docker.
|
||||
docker run --name mariadb -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -d mariadb
|
||||
|
||||
# Sleep for 25s to get MySQL get started.
|
||||
echo 'Sleeping for 25...'
|
||||
sleep 25
|
||||
|
||||
|
@ -44,7 +42,6 @@ up_percona() {
|
|||
# Run a SQL database on port 3306 inside of Docker.
|
||||
docker run --name percona -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -d percona
|
||||
|
||||
# Sleep for 20s
|
||||
echo 'Sleeping for 25...'
|
||||
sleep 25
|
||||
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
"""Remove reference to subdir
|
||||
|
||||
Revision ID: 53e2ac668296
|
||||
Revises: ed01e313d3cb
|
||||
Create Date: 2017-03-28 15:01:31.073382
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
import json
|
||||
|
||||
import logging
|
||||
from alembic.script.revision import RevisionError
|
||||
from alembic.util import CommandError
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
revision = '53e2ac668296'
|
||||
down_revision = 'ed01e313d3cb'
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def run_migration(migrate_function):
|
||||
conn = op.get_bind()
|
||||
triggers = conn.execute("SELECT id, config FROM repositorybuildtrigger")
|
||||
for trigger in triggers:
|
||||
config = json.dumps(migrate_function(json.loads(trigger[1])))
|
||||
try:
|
||||
conn.execute("UPDATE repositorybuildtrigger SET config=%s WHERE id=%s", config, trigger[0])
|
||||
except(RevisionError, CommandError) as e:
|
||||
log.warning("Failed to update build trigger %s with exception: ", trigger[0], e)
|
||||
|
||||
|
||||
def upgrade(tables):
|
||||
run_migration(delete_subdir)
|
||||
|
||||
|
||||
def downgrade(tables):
|
||||
run_migration(add_subdir)
|
||||
|
||||
|
||||
def delete_subdir(config):
|
||||
""" Remove subdir from config """
|
||||
if not config:
|
||||
return config
|
||||
if 'subdir' in config:
|
||||
del config['subdir']
|
||||
|
||||
return config
|
||||
|
||||
|
||||
def add_subdir(config):
|
||||
""" Add subdir back into config """
|
||||
if not config:
|
||||
return config
|
||||
if 'context' in config:
|
||||
config['subdir'] = config['context']
|
||||
|
||||
return config
|
Reference in a new issue