-- Deliverable types and templates
CREATE TABLE agency_deliverable_types (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
name text NOT NULL, -- 'automation_workflow', 'report', 'training'
category text NOT NULL, -- 'build', 'document', 'media', 'training'
-- Template
default_description text,
estimated_hours numeric,
-- Checklist items (JSON array)
checklist_template jsonb DEFAULT '[]',
created_at timestamptz DEFAULT now()
);
-- Deliverable versions (for revision tracking)
CREATE TABLE agency_deliverable_versions (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
deliverable_id uuid REFERENCES agency_deliverables(id),
version_number integer NOT NULL,
-- Snapshot
file_urls jsonb,
notes text,
-- Who created this version
created_by uuid REFERENCES auth.users(id),
created_at timestamptz DEFAULT now()
);
-- Deliverable feedback
CREATE TABLE agency_deliverable_feedback (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
deliverable_id uuid REFERENCES agency_deliverables(id),
version_id uuid REFERENCES agency_deliverable_versions(id),
-- Feedback content
feedback_type text NOT NULL, -- 'approval', 'revision_request', 'comment'
content text,
-- Who gave feedback
given_by uuid REFERENCES auth.users(id),
given_by_role text, -- 'client', 'pm', 'reviewer'
created_at timestamptz DEFAULT now()
);