Skip to content

Commit 4feff40

Browse files
authored
Merge pull request #182 from AOSSIE-Org/common_contracts
FEAT(analytics): add AI-powered analytics and campaign wall features
2 parents 83dd53e + 4f703e6 commit 4feff40

File tree

19 files changed

+7300
-95
lines changed

19 files changed

+7300
-95
lines changed

backend/SQL

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,3 +678,40 @@ CREATE INDEX IF NOT EXISTS idx_metric_update_requests_creator_id ON public.campa
678678
CREATE INDEX IF NOT EXISTS idx_metric_update_requests_status ON public.campaign_deliverable_metric_update_requests(status);
679679
CREATE INDEX IF NOT EXISTS idx_metric_audit_metric_id ON public.campaign_deliverable_metric_audit(campaign_deliverable_metric_id);
680680

681+
682+
683+
-- Migration SQL for Campaign Wall Feature
684+
-- Run this SQL in your Supabase SQL editor
685+
686+
-- 1. Add new columns to campaigns table for campaign wall feature
687+
ALTER TABLE public.campaigns
688+
ADD COLUMN IF NOT EXISTS is_open_for_applications boolean DEFAULT false,
689+
ADD COLUMN IF NOT EXISTS is_on_campaign_wall boolean DEFAULT false;
690+
691+
-- 2. Add indexes for better query performance
692+
CREATE INDEX IF NOT EXISTS idx_campaigns_is_open_for_applications ON public.campaigns(is_open_for_applications) WHERE is_open_for_applications = true;
693+
CREATE INDEX IF NOT EXISTS idx_campaigns_is_on_campaign_wall ON public.campaigns(is_on_campaign_wall) WHERE is_on_campaign_wall = true;
694+
CREATE INDEX IF NOT EXISTS idx_campaigns_open_and_wall ON public.campaigns(is_open_for_applications, is_on_campaign_wall) WHERE is_open_for_applications = true AND is_on_campaign_wall = true;
695+
696+
-- 3. Add new columns to campaign_applications table
697+
ALTER TABLE public.campaign_applications
698+
ADD COLUMN IF NOT EXISTS payment_min numeric,
699+
ADD COLUMN IF NOT EXISTS payment_max numeric,
700+
ADD COLUMN IF NOT EXISTS timeline_days integer,
701+
ADD COLUMN IF NOT EXISTS timeline_weeks integer,
702+
ADD COLUMN IF NOT EXISTS description text;
703+
704+
-- 4. Add index for campaign_applications status filtering
705+
CREATE INDEX IF NOT EXISTS idx_campaign_applications_status ON public.campaign_applications(status);
706+
CREATE INDEX IF NOT EXISTS idx_campaign_applications_campaign_status ON public.campaign_applications(campaign_id, status);
707+
CREATE INDEX IF NOT EXISTS idx_campaign_applications_creator_status ON public.campaign_applications(creator_id, status);
708+
709+
-- 5. Add comment for documentation
710+
COMMENT ON COLUMN public.campaigns.is_open_for_applications IS 'Whether this campaign accepts applications from creators';
711+
COMMENT ON COLUMN public.campaigns.is_on_campaign_wall IS 'Whether this campaign is visible on the public campaign wall';
712+
COMMENT ON COLUMN public.campaign_applications.payment_min IS 'Minimum payment amount the creator is requesting';
713+
COMMENT ON COLUMN public.campaign_applications.payment_max IS 'Maximum payment amount the creator is requesting';
714+
COMMENT ON COLUMN public.campaign_applications.timeline_days IS 'Number of days the creator estimates to complete the campaign';
715+
COMMENT ON COLUMN public.campaign_applications.timeline_weeks IS 'Number of weeks the creator estimates to complete the campaign';
716+
COMMENT ON COLUMN public.campaign_applications.description IS 'Creator description explaining why they should be chosen for this campaign';
717+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
-- Migration SQL for Campaign Wall Feature
2+
-- Run this SQL in your Supabase SQL editor
3+
4+
-- 1. Add new columns to campaigns table for campaign wall feature
5+
ALTER TABLE public.campaigns
6+
ADD COLUMN IF NOT EXISTS is_open_for_applications boolean DEFAULT false,
7+
ADD COLUMN IF NOT EXISTS is_on_campaign_wall boolean DEFAULT false;
8+
9+
-- 2. Add indexes for better query performance
10+
CREATE INDEX IF NOT EXISTS idx_campaigns_is_open_for_applications ON public.campaigns(is_open_for_applications) WHERE is_open_for_applications = true;
11+
CREATE INDEX IF NOT EXISTS idx_campaigns_is_on_campaign_wall ON public.campaigns(is_on_campaign_wall) WHERE is_on_campaign_wall = true;
12+
CREATE INDEX IF NOT EXISTS idx_campaigns_open_and_wall ON public.campaigns(is_open_for_applications, is_on_campaign_wall) WHERE is_open_for_applications = true AND is_on_campaign_wall = true;
13+
14+
-- 3. Add new columns to campaign_applications table
15+
ALTER TABLE public.campaign_applications
16+
ADD COLUMN IF NOT EXISTS payment_min numeric,
17+
ADD COLUMN IF NOT EXISTS payment_max numeric,
18+
ADD COLUMN IF NOT EXISTS timeline_days integer,
19+
ADD COLUMN IF NOT EXISTS timeline_weeks integer,
20+
ADD COLUMN IF NOT EXISTS description text;
21+
22+
-- 4. Add index for campaign_applications status filtering
23+
CREATE INDEX IF NOT EXISTS idx_campaign_applications_status ON public.campaign_applications(status);
24+
CREATE INDEX IF NOT EXISTS idx_campaign_applications_campaign_status ON public.campaign_applications(campaign_id, status);
25+
CREATE INDEX IF NOT EXISTS idx_campaign_applications_creator_status ON public.campaign_applications(creator_id, status);
26+
27+
-- 5. Add 'reviewing' to application_status enum if it doesn't exist
28+
DO $$
29+
BEGIN
30+
-- Check if 'reviewing' value exists in the enum
31+
IF NOT EXISTS (
32+
SELECT 1
33+
FROM pg_enum
34+
WHERE enumlabel = 'reviewing'
35+
AND enumtypid = (SELECT oid FROM pg_type WHERE typname = 'application_status')
36+
) THEN
37+
-- Add 'reviewing' to the enum
38+
-- Note: PostgreSQL doesn't support IF NOT EXISTS for ALTER TYPE ADD VALUE
39+
-- So we check first, then add if needed
40+
ALTER TYPE application_status ADD VALUE 'reviewing';
41+
END IF;
42+
EXCEPTION
43+
WHEN duplicate_object THEN
44+
-- Value already exists, ignore
45+
NULL;
46+
END $$;
47+
48+
-- 6. Add comment for documentation
49+
COMMENT ON COLUMN public.campaigns.is_open_for_applications IS 'Whether this campaign accepts applications from creators';
50+
COMMENT ON COLUMN public.campaigns.is_on_campaign_wall IS 'Whether this campaign is visible on the public campaign wall';
51+
COMMENT ON COLUMN public.campaign_applications.payment_min IS 'Minimum payment amount the creator is requesting';
52+
COMMENT ON COLUMN public.campaign_applications.payment_max IS 'Maximum payment amount the creator is requesting';
53+
COMMENT ON COLUMN public.campaign_applications.timeline_days IS 'Number of days the creator estimates to complete the campaign';
54+
COMMENT ON COLUMN public.campaign_applications.timeline_weeks IS 'Number of weeks the creator estimates to complete the campaign';
55+
COMMENT ON COLUMN public.campaign_applications.description IS 'Creator description explaining why they should be chosen for this campaign';
56+

0 commit comments

Comments
 (0)