"""add unique constraint on GL business fields

Revision ID: 1dc30166cf33
Revises: 8a3306b48353
Create Date: 2025-05-27 00:42:04.175037

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '1dc30166cf33'
down_revision: Union[str, None] = '8a3306b48353'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.create_unique_constraint(
    "uq_gl_business_fields",
    "general_ledger",
    [
        "general_ledger_code",
        "account_name",
        "category",
        "date",
        "debit",
        "credit",
    ],
)


def downgrade() -> None:
    op.drop_constraint("uq_gl_business_fields", "general_ledger", type_="unique")

