-- Migration: Add membership fields to companies table
-- Run this script to add membership/subscription functionality

ALTER TABLE companies 
ADD COLUMN fecha_inicio DATE NULL,
ADD COLUMN fecha_fin DATE NULL,
ADD COLUMN meses_activos INT DEFAULT 0;

-- Create index for faster queries
CREATE INDEX idx_companies_fecha_fin ON companies(fecha_fin);

-- Update existing active companies (optional: set them as having lifetime or 12 months)
-- This is just for reference, adjust as needed
-- UPDATE companies SET fecha_inicio = CURDATE(), fecha_fin = DATE_ADD(CURDATE(), INTERVAL 12 MONTH), meses_activos = 12 WHERE estado = 'activo';
