From 86ee174c9d81c0ed5672113fcd8e76cf30c671ec Mon Sep 17 00:00:00 2001 From: doc Date: Sat, 28 Jun 2025 21:03:28 +0000 Subject: inital commit --- .../27b841f29edb_add_email_column_to_user_table.py | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 migrations/versions/27b841f29edb_add_email_column_to_user_table.py (limited to 'migrations/versions/27b841f29edb_add_email_column_to_user_table.py') diff --git a/migrations/versions/27b841f29edb_add_email_column_to_user_table.py b/migrations/versions/27b841f29edb_add_email_column_to_user_table.py new file mode 100644 index 0000000..08fedf7 --- /dev/null +++ b/migrations/versions/27b841f29edb_add_email_column_to_user_table.py @@ -0,0 +1,84 @@ +"""Add email column to user table + +Revision ID: 27b841f29edb +Revises: +Create Date: 2025-04-24 18:14:20.471072 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '27b841f29edb' +down_revision = None +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('toot', schema=None) as batch_op: + batch_op.alter_column('message', + existing_type=sa.VARCHAR(length=512), + type_=sa.String(length=255), + existing_nullable=False) + batch_op.alter_column('toot_time', + existing_type=sa.VARCHAR(length=8), + type_=sa.String(length=5), + existing_nullable=False) + batch_op.alter_column('day', + existing_type=sa.VARCHAR(length=10), + type_=sa.String(length=9), + existing_nullable=False) + + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.add_column(sa.Column('email', sa.String(length=120), nullable=False)) + batch_op.add_column(sa.Column('password', sa.String(length=200), nullable=False)) + batch_op.alter_column('id', + existing_type=sa.VARCHAR(length=36), + type_=sa.Integer(), + existing_nullable=False, + autoincrement=True) + batch_op.alter_column('username', + existing_type=sa.VARCHAR(length=80), + type_=sa.String(length=100), + existing_nullable=False) + batch_op.create_unique_constraint(None, ['email']) + batch_op.drop_column('password_hash') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('user', schema=None) as batch_op: + batch_op.add_column(sa.Column('password_hash', sa.VARCHAR(length=128), autoincrement=False, nullable=False)) + batch_op.drop_constraint(None, type_='unique') + batch_op.alter_column('username', + existing_type=sa.String(length=100), + type_=sa.VARCHAR(length=80), + existing_nullable=False) + batch_op.alter_column('id', + existing_type=sa.Integer(), + type_=sa.VARCHAR(length=36), + existing_nullable=False, + autoincrement=True) + batch_op.drop_column('password') + batch_op.drop_column('email') + + with op.batch_alter_table('toot', schema=None) as batch_op: + batch_op.alter_column('day', + existing_type=sa.String(length=9), + type_=sa.VARCHAR(length=10), + existing_nullable=False) + batch_op.alter_column('toot_time', + existing_type=sa.String(length=5), + type_=sa.VARCHAR(length=8), + existing_nullable=False) + batch_op.alter_column('message', + existing_type=sa.String(length=255), + type_=sa.VARCHAR(length=512), + existing_nullable=False) + + # ### end Alembic commands ### -- cgit v1.2.3