app-MAIL-temp/migrations/versions/2020_040922_ea30c0b5b2e3_.py
2020-04-09 22:20:06 +02:00

43 lines
1.4 KiB
Python

"""empty message
Revision ID: ea30c0b5b2e3
Revises: 497cfd2a02e2
Create Date: 2020-04-09 22:16:58.923473
"""
import sqlalchemy_utils
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'ea30c0b5b2e3'
down_revision = '497cfd2a02e2'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('referral',
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('code', sa.String(length=128), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('code')
)
op.add_column('users', sa.Column('referral_id', sa.Integer(), nullable=True))
op.create_foreign_key(None, 'users', 'referral', ['referral_id'], ['id'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'users', type_='foreignkey')
op.drop_column('users', 'referral_id')
op.drop_table('referral')
# ### end Alembic commands ###