-- Add treelogy_id column to forms table
ALTER TABLE public.forms 
ADD COLUMN treelogy_id INTEGER;

-- Add comment to the column
COMMENT ON COLUMN public.forms.treelogy_id IS 'Project/Treelogy ID this form belongs to';

-- Create index for better query performance
CREATE INDEX forms_treelogy_id_idx ON public.forms(treelogy_id);

-- Add foreign key constraint (optional - only if you want to enforce referential integrity)
-- ALTER TABLE public.forms 
-- ADD CONSTRAINT fk_forms_treelogy 
--     FOREIGN KEY (treelogy_id) 
--     REFERENCES public.treelogy(treelogy_id)
--     ON UPDATE CASCADE 
--     ON DELETE SET NULL;

-- Verify the column was added
SELECT column_name, data_type, is_nullable, column_default
FROM information_schema.columns 
WHERE table_name = 'forms' 
  AND table_schema = 'public'
  AND column_name = 'treelogy_id';



