From ed11363b0c2f351017df7cfd33aaef2395e12a63 Mon Sep 17 00:00:00 2001 From: Son NK Date: Thu, 27 Feb 2020 22:26:35 +0700 Subject: [PATCH] add db migration script --- .../versions/2020_022722_75093e7ded27_.py | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 migrations/versions/2020_022722_75093e7ded27_.py diff --git a/migrations/versions/2020_022722_75093e7ded27_.py b/migrations/versions/2020_022722_75093e7ded27_.py new file mode 100644 index 00000000..b7a0f9b9 --- /dev/null +++ b/migrations/versions/2020_022722_75093e7ded27_.py @@ -0,0 +1,50 @@ +"""empty message + +Revision ID: 75093e7ded27 +Revises: e3cb44b953f2 +Create Date: 2020-02-27 22:26:25.068117 + +""" +import sqlalchemy_utils +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '75093e7ded27' +down_revision = 'e3cb44b953f2' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('social_auth', + 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('social', sa.String(length=128), nullable=False), + sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('user_id', 'social', name='uq_social_auth') + ) + op.alter_column('users', 'password', + existing_type=sa.VARCHAR(length=128), + nullable=True) + op.alter_column('users', 'salt', + existing_type=sa.VARCHAR(length=128), + nullable=True) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('users', 'salt', + existing_type=sa.VARCHAR(length=128), + nullable=False) + op.alter_column('users', 'password', + existing_type=sa.VARCHAR(length=128), + nullable=False) + op.drop_table('social_auth') + # ### end Alembic commands ###