fastapi-svelte-template/backend/todo/database/migrations/versions/335e07a98bc8_create_user_tables.py

35 lines
975 B
Python
Raw Normal View History

"""create user tables
Revision ID: 335e07a98bc8
Revises:
Create Date: 2023-05-12 19:59:22.188464
"""
from alembic import op
from sqlalchemy import Column, Integer, String, DateTime
from sqlalchemy.sql.functions import now
# revision identifiers, used by Alembic.
revision = '335e07a98bc8'
down_revision = None
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_table(
'users',
Column('id', Integer, primary_key=True, autoincrement=True, index=True),
Column('email', String, unique=True, nullable=False),
Column('password', String, nullable=False),
Column('created', DateTime(timezone=True), nullable=False, server_default=now()),
Column('updated', DateTime(timezone=True), nullable=False, server_default=now(), onupdate=now()),
Column('first_name', String, nullable=False),
Column('last_name', String, nullable=False),
)
def downgrade() -> None:
op.drop_table('users')