-- Fix gl_expense_types to use INTEGER for account IDs instead of UUID
-- This matches the gl_accounts table which uses SERIAL (INTEGER) IDs

ALTER TABLE gl_expense_types 
    ALTER COLUMN expense_account_id TYPE INTEGER USING NULL,
    ALTER COLUMN vat_account_id TYPE INTEGER USING NULL,
    ALTER COLUMN payable_account_id TYPE INTEGER USING NULL;

-- Add foreign key constraints
ALTER TABLE gl_expense_types
    ADD CONSTRAINT fk_expense_account FOREIGN KEY (expense_account_id) REFERENCES gl_accounts(id) ON DELETE SET NULL,
    ADD CONSTRAINT fk_vat_account FOREIGN KEY (vat_account_id) REFERENCES gl_accounts(id) ON DELETE SET NULL,
    ADD CONSTRAINT fk_payable_account FOREIGN KEY (payable_account_id) REFERENCES gl_accounts(id) ON DELETE SET NULL;
