Compare commits

...

2 Commits

2 changed files with 45 additions and 1 deletions

View File

@ -7,7 +7,7 @@
# set to 'true' to run the environment during # set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate # the 'revision' command, regardless of autogenerate
# revision_environment = false # revision_environment = false
script_location = .
# Logging configuration # Logging configuration
[loggers] [loggers]

View File

@ -0,0 +1,44 @@
"""split user to user and profile
Revision ID: de2164c615e8
Revises: 575a8924eb16
Create Date: 2021-06-20 14:17:02.102076
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'de2164c615e8'
down_revision = '575a8924eb16'
branch_labels = None
depends_on = None
def upgrade():
op.create_table('user_profile',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('pronouns', sa.String(length=25), nullable=True),
sa.Column('volunteerwork', sa.String(length=4000), nullable=True),
sa.Column('freetext', sa.String(length=4000), nullable=True),
sa.Column('created', sa.DateTime(), nullable=False),
sa.Column('updated', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id'),
)
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
op.execute("INSERT INTO user_profile (user_id,pronouns,volunteerwork,freetext,created,updated) SELECT id,pronouns,volunteerwork,freetext,created,updated FROM user")
op.drop_column("user","pronouns")
op.drop_column("user","volunteerwork")
op.drop_column("user","freetext")
def downgrade():
op.add_column("user", Column('pronouns', sa.String(length=25), nullable=True))
op.add_column("user", Column("volunteerwork",sa.String(length=4000), nullable=True))
op.add_column("user", Column("freetext",sa.String(length=4000), nullable=True))
# tbd update user table fields from user profile fields
op.drop_table('user_profile')