Generate migration -- do not run in production

This is the migration that was automatically generated. If you run this
version, historical data WILL be corrupted beyond repair.
This commit is contained in:
Midgard 2020-01-26 16:26:17 +01:00
parent 6d7baa31ea
commit ecaff42ba4
Signed by: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -0,0 +1,87 @@
"""Initial HLDS support
Revision ID: 9159a6fed021
Revises: 150252c1cdb1
Create Date: 2020-01-26 16:22:00.935963
"""
# revision identifiers, used by Alembic.
revision = '9159a6fed021'
down_revision = '150252c1cdb1'
from alembic import op
import sqlalchemy as sa
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('order_item_choice',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('choice_id', sa.String(length=64), nullable=True),
sa.Column('order_item_id', sa.Integer(), nullable=False),
sa.Column('kind', sa.String(length=1), nullable=False),
sa.Column('name', sa.String(length=120), nullable=True),
sa.Column('value', sa.String(length=120), nullable=True),
sa.ForeignKeyConstraint(['order_item_id'], ['order_item.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.drop_table('product')
op.drop_table('location')
op.add_column('order', sa.Column('courier_id', sa.Integer(), nullable=True))
op.add_column('order', sa.Column('location_name', sa.String(length=128), nullable=True))
op.drop_constraint(None, 'order', type_='foreignkey')
op.drop_column('order', 'courrier_id')
op.add_column('order_item', sa.Column('comment', sa.Text(), nullable=True))
op.add_column('order_item', sa.Column('dish_id', sa.String(length=120), nullable=True))
op.add_column('order_item', sa.Column('dish_name', sa.String(length=120), nullable=True))
op.add_column('order_item', sa.Column('hlds_data_version', sa.String(length=40), nullable=True))
op.add_column('order_item', sa.Column('price', sa.Integer(), nullable=False))
op.add_column('order_item', sa.Column('user_name', sa.String(length=120), nullable=True))
op.alter_column('order_item', 'paid',
existing_type=sa.BOOLEAN(),
nullable=False)
op.drop_constraint(None, 'order_item', type_='foreignkey')
op.drop_column('order_item', 'product_id')
op.drop_column('order_item', 'name')
op.drop_column('order_item', 'extra')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('order_item', sa.Column('extra', sa.VARCHAR(length=254), nullable=True))
op.add_column('order_item', sa.Column('name', sa.VARCHAR(length=120), nullable=True))
op.add_column('order_item', sa.Column('product_id', sa.INTEGER(), nullable=True))
op.create_foreign_key(None, 'order_item', 'product', ['product_id'], ['id'])
op.alter_column('order_item', 'paid',
existing_type=sa.BOOLEAN(),
nullable=True)
op.drop_column('order_item', 'user_name')
op.drop_column('order_item', 'price')
op.drop_column('order_item', 'hlds_data_version')
op.drop_column('order_item', 'dish_name')
op.drop_column('order_item', 'dish_id')
op.drop_column('order_item', 'comment')
op.add_column('order', sa.Column('courrier_id', sa.INTEGER(), nullable=True))
op.create_foreign_key(None, 'order', 'location', ['location_id'], ['id'])
op.drop_column('order', 'location_name')
op.drop_column('order', 'courier_id')
op.create_table('location',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('name', sa.VARCHAR(length=120), nullable=False),
sa.Column('address', sa.VARCHAR(length=254), nullable=True),
sa.Column('website', sa.VARCHAR(length=120), nullable=True),
sa.Column('telephone', sa.VARCHAR(length=20), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('product',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('location_id', sa.INTEGER(), nullable=True),
sa.Column('name', sa.VARCHAR(length=120), nullable=False),
sa.Column('price', sa.INTEGER(), nullable=False),
sa.ForeignKeyConstraint(['location_id'], ['location.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.drop_table('order_item_choice')
# ### end Alembic commands ###