# Copyright 2016 Mirantis, Inc. # # 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. """Release column added to installation_structures Revision ID: 24081e26a283 Revises: 2ec36f35eeaa Create Date: 2016-06-23 18:53:01.431773 """ # revision identifiers, used by Alembic. revision = '24081e26a283' down_revision = '2ec36f35eeaa' from alembic import op import sqlalchemy as sa def upgrade(): ### commands auto generated by Alembic - please adjust! ### op.add_column( 'installation_structures', sa.Column('release', sa.Text(), nullable=True) ) op.create_index( op.f('ix_installation_structures_release'), 'installation_structures', ['release'], unique=False ) set_release = sa.sql.text( "UPDATE installation_structures " "SET release = structure->'fuel_release'->>'release'" ) connection = op.get_bind() connection.execute(set_release) ### end Alembic commands ### def downgrade(): ### commands auto generated by Alembic - please adjust! ### op.drop_index( op.f('ix_installation_structures_release'), table_name='installation_structures' ) op.drop_column('installation_structures', 'release') ### end Alembic commands ###