"""add tenant code prefix and domain fields to installation_tenant_info

Revision ID: 844ac73765a3
Revises: ba655ef20407
Create Date: 2026-02-23 00:33:56.554891

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '844ac73765a3'
down_revision: Union[str, None] = 'ba655ef20407'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # 新增租戶代碼和員工編號前綴欄位
    op.add_column('installation_tenant_info', sa.Column('tenant_code', sa.String(50), nullable=True))
    op.add_column('installation_tenant_info', sa.Column('tenant_prefix', sa.String(10), nullable=True))

    # 新增郵件網域相關欄位
    op.add_column('installation_tenant_info', sa.Column('domain_set', sa.Integer, nullable=True, server_default='2'))
    op.add_column('installation_tenant_info', sa.Column('domain', sa.String(100), nullable=True))

    # 新增公司聯絡資訊欄位（對應 tenants 表）
    op.add_column('installation_tenant_info', sa.Column('tel', sa.String(20), nullable=True))
    op.add_column('installation_tenant_info', sa.Column('add', sa.Text, nullable=True))


def downgrade() -> None:
    # 移除欄位
    op.drop_column('installation_tenant_info', 'add')
    op.drop_column('installation_tenant_info', 'tel')
    op.drop_column('installation_tenant_info', 'domain')
    op.drop_column('installation_tenant_info', 'domain_set')
    op.drop_column('installation_tenant_info', 'tenant_prefix')
    op.drop_column('installation_tenant_info', 'tenant_code')
