Add sql migration

This commit is contained in:
Son NK 2020-04-19 11:18:42 +02:00
parent 71d53d16da
commit 11772d35e1

View file

@ -0,0 +1,47 @@
"""empty message
Revision ID: dd911f880b75
Revises: 57ef03f3ac34
Create Date: 2020-04-19 11:14:19.929910
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'dd911f880b75'
down_revision = '57ef03f3ac34'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('apple_subscription',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
sa.Column('updated_at', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('expires_date', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
sa.Column('original_transaction_id', sa.String(length=256), nullable=False),
sa.Column('receipt_data', sa.Text(), nullable=False),
sa.Column('plan', sa.Enum('monthly', 'yearly', name='planenum'), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('user_id')
)
op.alter_column('file', 'user_id',
existing_type=sa.INTEGER(),
nullable=True)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('file', 'user_id',
existing_type=sa.INTEGER(),
nullable=False)
op.drop_table('apple_subscription')
# ### end Alembic commands ###