diff --git a/api.cfm b/api.cfm index cf8163d..05228bd 100644 --- a/api.cfm +++ b/api.cfm @@ -1,66 +1,111 @@ - + - - - - + + + - + SELECT 1 as ok - + SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' ORDER BY table_name - + - - - - - - #preserveSingleQuotes(sql)# - - - - - + + + + + CREATE TABLE IF NOT EXISTS documents ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + filename TEXT NOT NULL, mime_type TEXT NOT NULL, + original_bytes BYTEA, parsed_text TEXT, elements_json JSONB, + status TEXT DEFAULT 'uploaded', error_message TEXT, + created_at TIMESTAMPTZ DEFAULT now() + ) + + + + + + + CREATE TABLE IF NOT EXISTS contracts ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + number TEXT NOT NULL, client TEXT, date_signed DATE, + status TEXT DEFAULT 'active', created_at TIMESTAMPTZ DEFAULT now() + ) + + + + + + + CREATE TABLE IF NOT EXISTS supplements ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + contract_id UUID REFERENCES contracts(id), + number TEXT, date_signed DATE, type TEXT DEFAULT 'initial', + document_id UUID REFERENCES documents(id), + created_at TIMESTAMPTZ DEFAULT now() + ) + + + + + + + CREATE TABLE IF NOT EXISTS spec_rows ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + supplement_id UUID REFERENCES supplements(id), + row_num INTEGER, name TEXT, price NUMERIC, qty NUMERIC, + sum NUMERIC, date_start DATE, date_end DATE, + created_at TIMESTAMPTZ DEFAULT now() + ) + + + + + + + CREATE TABLE IF NOT EXISTS spec_history ( + id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + contract_id UUID REFERENCES contracts(id), + supplement_id UUID REFERENCES supplements(id), + row_num INTEGER, change_type TEXT NOT NULL, + old_values JSONB, new_values JSONB, + created_at TIMESTAMPTZ DEFAULT now() + ) + + + + - + #preserveSingleQuotes(url.sql)# - - + + - + - - - #preserveSingleQuotes(body.sql)# + + + #preserveSingleQuotes(body.sql)# - + + + + #serializeJSON(result)# -