"""Make credit_notes.customer_id nullable for walk-in customers."""

import os
import sys

from sqlalchemy import text

# Ensure project root is on sys.path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from app.core.database import engine


def main() -> None:
    with engine.begin() as conn:
        conn.execute(text("""
            ALTER TABLE credit_notes
            ALTER COLUMN customer_id DROP NOT NULL
        """))
        print("Updated credit_notes.customer_id to allow NULL values.")


if __name__ == "__main__":
    main()
