mirror of
https://github.com/simple-login/app.git
synced 2024-11-10 17:35:27 +08:00
add db migration script
This commit is contained in:
parent
9d23fc5ab3
commit
ed11363b0c
1 changed files with 50 additions and 0 deletions
50
migrations/versions/2020_022722_75093e7ded27_.py
Normal file
50
migrations/versions/2020_022722_75093e7ded27_.py
Normal file
|
@ -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 ###
|
Loading…
Reference in a new issue