app-MAIL-temp/migrations/versions/4a640c170d02_.py

54 lines
2.3 KiB
Python
Raw Normal View History

"""empty message
Revision ID: 4a640c170d02
Revises: 5fa68bafae72
Create Date: 2019-11-14 14:47:36.440551
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '4a640c170d02'
down_revision = '5fa68bafae72'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('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('cancel_url', sa.String(length=1024), nullable=False),
sa.Column('update_url', sa.String(length=1024), nullable=False),
sa.Column('subscription_id', sa.String(length=1024), nullable=False),
sa.Column('event_time', sqlalchemy_utils.types.arrow.ArrowType(), nullable=False),
sa.Column('next_bill_date', sa.Date(), nullable=False),
sa.Column('cancelled', sa.Boolean(), nullable=False),
2019-11-14 15:22:32 +01:00
sa.Column('plan', sa.Enum('monthly', 'yearly', name='planenum2'), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('subscription_id'),
sa.UniqueConstraint('user_id')
)
op.add_column('users', sa.Column('trial_expiration', sqlalchemy_utils.types.arrow.ArrowType(), nullable=True))
op.drop_column('users', 'plan_expiration')
op.drop_column('users', 'plan')
op.drop_column('users', 'promo_codes')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('users', sa.Column('promo_codes', sa.TEXT(), autoincrement=False, nullable=True))
op.add_column('users', sa.Column('plan', postgresql.ENUM('free', 'trial', 'monthly', 'yearly', name='plan_enum'), server_default=sa.text("'free'::plan_enum"), autoincrement=False, nullable=False))
op.add_column('users', sa.Column('plan_expiration', postgresql.TIMESTAMP(), autoincrement=False, nullable=True))
op.drop_column('users', 'trial_expiration')
op.drop_table('subscription')
# ### end Alembic commands ###