-- Fix organization table schema - extend VARCHAR fields to handle long TED data
-- Run this manually if Flyway migration V2 hasn't been applied yet
-- Usage: psql -h 94.130.218.54 -p 32333 -U postgres -d RELM -f fix-organization-schema.sql

-- Check current schema
\d ted.organization

-- Extend VARCHAR fields in organization table
ALTER TABLE ted.organization ALTER COLUMN postal_code TYPE VARCHAR(255);
ALTER TABLE ted.organization ALTER COLUMN street_name TYPE TEXT;
ALTER TABLE ted.organization ALTER COLUMN city TYPE VARCHAR(255);
ALTER TABLE ted.organization ALTER COLUMN phone TYPE VARCHAR(100);
ALTER TABLE ted.organization ALTER COLUMN org_reference TYPE VARCHAR(100);
ALTER TABLE ted.organization ALTER COLUMN role TYPE VARCHAR(100);

-- Verify changes
\d ted.organization

-- Show what was changed
SELECT 'Schema updated successfully' AS result;
