-- Adiciona campos para identificar contas de alunos na tabela receivables
-- Execute este script no banco de dados

ALTER TABLE receivables
ADD COLUMN student_id INT NULL COMMENT 'ID do aluno (se for parcela de venda de aluno)' 
AFTER supplier_id,
ADD COLUMN student_sale_id INT NULL COMMENT 'ID da venda do aluno' 
AFTER student_id,
ADD COLUMN numero_parcela INT NULL COMMENT 'Número da parcela (ex: 1, 2, 3)' 
AFTER student_sale_id,
ADD COLUMN total_parcelas INT NULL COMMENT 'Total de parcelas (ex: 3, 6, 12)' 
AFTER numero_parcela,
ADD INDEX idx_student_id (student_id),
ADD INDEX idx_student_sale_id (student_sale_id),
ADD FOREIGN KEY (student_id) REFERENCES students(id) ON DELETE CASCADE,
ADD FOREIGN KEY (student_sale_id) REFERENCES student_sales(id) ON DELETE CASCADE;

