From 11772d35e1ac59306a1b3ca01dcd2bb235a04d85 Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Sun, 19 Apr 2020 11:18:42 +0200 Subject: [PATCH] Add sql migration --- .../versions/2020_041911_dd911f880b75_.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 migrations/versions/2020_041911_dd911f880b75_.py diff --git a/migrations/versions/2020_041911_dd911f880b75_.py b/migrations/versions/2020_041911_dd911f880b75_.py new file mode 100644 index 00000000..674b71e6 --- /dev/null +++ b/migrations/versions/2020_041911_dd911f880b75_.py @@ -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 ###