"""add project certificate defaults

Revision ID: 20260602_0002
Revises: 20260601_0001
Create Date: 2026-06-02
"""

from alembic import op
import sqlalchemy as sa


revision = "20260602_0002"
down_revision = "20260601_0001"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.add_column("project_courses", sa.Column("default_certificate_name", sa.String(length=128), nullable=True))
    op.add_column("project_courses", sa.Column("default_course_name", sa.String(length=128), nullable=True))
    op.add_column("project_courses", sa.Column("default_stage_name", sa.String(length=128), nullable=True))
    op.add_column("project_courses", sa.Column("default_issuer_name", sa.String(length=128), nullable=True))
    op.execute("update project_courses set default_certificate_name='培训结业证书' where default_certificate_name is null")
    op.execute("update project_courses set default_course_name=name where default_course_name is null")
    op.execute("update project_courses set default_issuer_name='本公司' where default_issuer_name is null")


def downgrade() -> None:
    op.drop_column("project_courses", "default_issuer_name")
    op.drop_column("project_courses", "default_stage_name")
    op.drop_column("project_courses", "default_course_name")
    op.drop_column("project_courses", "default_certificate_name")
