<reponame>NeCTAR-RC/warre
"""flavorproject id to uuid

Revision ID: 56280d4f9db9
Revises: <PASSWORD>
Create Date: 2021-05-12 07:45:56.711460

"""
from alembic import op
from oslo_utils import uuidutils
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
from sqlalchemy.ext.declarative import declarative_base


# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '<PASSWORD>'
branch_labels = None
depends_on = None

Base = declarative_base()


def upgrade():
    class FlavorProjectUUID(Base):
        __tablename__ = 'flavor_project'
        id = sa.Column(sa.String(64), primary_key=True)

    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('flavor_project', 'id',
               existing_type=mysql.INTEGER(display_width=11),
               type_=sa.String(length=64),
               existing_nullable=False)
    # ### end Alembic commands ###

    session = sa.orm.Session(bind=op.get_bind())
    for fp in session.query(FlavorProjectUUID):
        fp.id = uuidutils.generate_uuid()

        session.add(fp)
    session.commit()


def downgrade():
    class FlavorProjectInt(Base):
        __tablename__ = 'flavor_project'
        id = sa.Column(sa.Integer, primary_key=True)

    session = sa.orm.Session(bind=op.get_bind())
    index = 1
    for fp in session.query(FlavorProjectInt):
        fp.id = index
        index += 1

        session.add(fp)
    session.commit()

    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('flavor_project', 'id',
               existing_type=sa.String(length=64),
               type_=mysql.INTEGER(display_width=11),
               existing_nullable=False)
    # ### end Alembic commands ###

"""flavorproject id to uuid

Revision ID: 56280d4f9db9
Revises: <PASSWORD>
Create Date: 2021-05-12 07:45:56.711460

"""
from alembic import op
from oslo_utils import uuidutils
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
from sqlalchemy.ext.declarative import declarative_base


# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '<PASSWORD>'
branch_labels = None
depends_on = None

Base = declarative_base()


def upgrade():
    class FlavorProjectUUID(Base):
        __tablename__ = 'flavor_project'
        id = sa.Column(sa.String(64), primary_key=True)

    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('flavor_project', 'id',
               existing_type=mysql.INTEGER(display_width=11),
               type_=sa.String(length=64),
               existing_nullable=False)
    # ### end Alembic commands ###

    session = sa.orm.Session(bind=op.get_bind())
    for fp in session.query(FlavorProjectUUID):
        fp.id = uuidutils.generate_uuid()

        session.add(fp)
    session.commit()


def downgrade():
    class FlavorProjectInt(Base):
        __tablename__ = 'flavor_project'
        id = sa.Column(sa.Integer, primary_key=True)

    session = sa.orm.Session(bind=op.get_bind())
    index = 1
    for fp in session.query(FlavorProjectInt):
        fp.id = index
        index += 1

        session.add(fp)
    session.commit()

    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('flavor_project', 'id',
               existing_type=sa.String(length=64),
               type_=mysql.INTEGER(display_width=11),
               existing_nullable=False)
    # ### end Alembic commands ###
flavorproject id to uuid  Revision ID: 56280d4f9db9 Revises: <PASSWORD> Create Date: 2021-05-12 07:45:56.711460 # revision identifiers, used by Alembic. # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ### # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ###