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

36 lines
1.1 KiB
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
2023-05-31 16:37:56 +01:00
from sqlalchemy import Column, Integer, String, DateTime, Boolean
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, index=True),
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, index=True),
2023-05-31 16:37:56 +01:00
Column('is_admin', Boolean, nullable=False, default=False, index=True),
)
def downgrade() -> None:
op.drop_table('users')