48 lines
2.1 KiB
Python
48 lines
2.1 KiB
Python
"""add location to olt_devices
|
|
|
|
Revision ID: 32c84173ef05
|
|
Revises: 5c24b07e0f9c
|
|
Create Date: 2026-04-02 10:52:19.883293
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = '32c84173ef05'
|
|
down_revision: Union[str, None] = '5c24b07e0f9c'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f('ix_users_id'), table_name='users')
|
|
op.drop_table('users')
|
|
op.add_column('olt_devices', sa.Column('location', sa.String(length=200), nullable=True))
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_column('olt_devices', 'location')
|
|
op.create_table('users',
|
|
sa.Column('id', sa.BIGINT(), autoincrement=True, nullable=False),
|
|
sa.Column('casdoor_id', sa.VARCHAR(length=100), autoincrement=False, nullable=False),
|
|
sa.Column('username', sa.VARCHAR(length=100), autoincrement=False, nullable=False),
|
|
sa.Column('email', sa.VARCHAR(length=255), autoincrement=False, nullable=True),
|
|
sa.Column('role', sa.VARCHAR(length=50), autoincrement=False, nullable=True),
|
|
sa.Column('assigned_area', sa.VARCHAR(length=100), autoincrement=False, nullable=True),
|
|
sa.Column('assigned_school', sa.VARCHAR(length=200), autoincrement=False, nullable=True),
|
|
sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=True),
|
|
sa.Column('last_login', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
|
|
sa.Column('created_at', postgresql.TIMESTAMP(), server_default=sa.text('now()'), autoincrement=False, nullable=True),
|
|
sa.PrimaryKeyConstraint('id', name=op.f('users_pkey')),
|
|
sa.UniqueConstraint('casdoor_id', name=op.f('users_casdoor_id_key'), postgresql_include=[], postgresql_nulls_not_distinct=False)
|
|
)
|
|
op.create_index(op.f('ix_users_id'), 'users', ['id'], unique=False)
|
|
# ### end Alembic commands ###
|