-- Add missing columns to eli_test.segment2 to match expected schema

ALTER TABLE eli_test.segment2
ADD COLUMN IF NOT EXISTS id_0 INTEGER,
ADD COLUMN IF NOT EXISTS mapid INTEGER,
ADD COLUMN IF NOT EXISTS segment_type VARCHAR(80),
ADD COLUMN IF NOT EXISTS segment_status VARCHAR(80),
ADD COLUMN IF NOT EXISTS id INTEGER,
ADD COLUMN IF NOT EXISTS protection_status VARCHAR(80),
ADD COLUMN IF NOT EXISTS qc_flag VARCHAR(255),
ADD COLUMN IF NOT EXISTS group_1 TEXT;

-- Copy "Group 1" data to group_1 if it exists
UPDATE eli_test.segment2 SET group_1 = "Group 1" WHERE "Group 1" IS NOT NULL;

-- Verify the new structure
\d eli_test.segment2
