Add migration for Person
This commit is contained in:
parent
e5f8acd8b8
commit
07d04306ab
36
alembic/versions/20250326_195724_7bcb215d_create_person.py
Normal file
36
alembic/versions/20250326_195724_7bcb215d_create_person.py
Normal file
@ -0,0 +1,36 @@
|
||||
"""create persons table
|
||||
|
||||
Revision ID: 1234567890ab
|
||||
Revises:
|
||||
Create Date: 2023-05-19 10:00:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1234567890ab'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table(
|
||||
'persons',
|
||||
sa.Column('id', UUID(as_uuid=True), primary_key=True),
|
||||
sa.Column('first_name', sa.String(), nullable=False),
|
||||
sa.Column('last_name', sa.String(), nullable=False),
|
||||
sa.Column('email', sa.String(), nullable=False, unique=True),
|
||||
sa.Column('phone_number', sa.String(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.func.now(), onupdate=sa.func.now())
|
||||
)
|
||||
op.create_index(op.f('ix_persons_email'), 'persons', ['email'], unique=True)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index(op.f('ix_persons_email'), table_name='persons')
|
||||
op.drop_table('persons')
|
Loading…
x
Reference in New Issue
Block a user