Mega push vol1
This commit is contained in:
3
supabase/migrations/007_org_theme.sql
Normal file
3
supabase/migrations/007_org_theme.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
-- Add theme color and icon to organizations
|
||||
ALTER TABLE organizations ADD COLUMN IF NOT EXISTS theme_color TEXT DEFAULT '#00a3e0';
|
||||
ALTER TABLE organizations ADD COLUMN IF NOT EXISTS icon_url TEXT;
|
||||
42
supabase/migrations/008_kanban_enhancements.sql
Normal file
42
supabase/migrations/008_kanban_enhancements.sql
Normal file
@@ -0,0 +1,42 @@
|
||||
-- Add assignee, due date, and checklist support to kanban cards
|
||||
|
||||
-- Add assignee_id to kanban_cards (references profiles)
|
||||
ALTER TABLE kanban_cards ADD COLUMN IF NOT EXISTS assignee_id UUID REFERENCES profiles(id) ON DELETE SET NULL;
|
||||
|
||||
-- Add due_date for SLA/deadline tracking
|
||||
ALTER TABLE kanban_cards ADD COLUMN IF NOT EXISTS due_date TIMESTAMPTZ;
|
||||
|
||||
-- Add priority field
|
||||
ALTER TABLE kanban_cards ADD COLUMN IF NOT EXISTS priority TEXT CHECK (priority IN ('low', 'medium', 'high', 'urgent')) DEFAULT 'medium';
|
||||
|
||||
-- Create checklist items table
|
||||
CREATE TABLE IF NOT EXISTS kanban_checklist_items (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
card_id UUID NOT NULL REFERENCES kanban_cards(id) ON DELETE CASCADE,
|
||||
title TEXT NOT NULL,
|
||||
completed BOOLEAN DEFAULT false,
|
||||
position INTEGER DEFAULT 0,
|
||||
created_at TIMESTAMPTZ DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ DEFAULT now()
|
||||
);
|
||||
|
||||
-- Enable RLS on checklist items
|
||||
ALTER TABLE kanban_checklist_items ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
-- Checklist items inherit access from the card's board -> org
|
||||
CREATE POLICY "Checklist items inherit card access" ON kanban_checklist_items
|
||||
FOR ALL USING (
|
||||
EXISTS (
|
||||
SELECT 1 FROM kanban_cards c
|
||||
JOIN kanban_columns col ON c.column_id = col.id
|
||||
JOIN kanban_boards b ON col.board_id = b.id
|
||||
JOIN org_members m ON b.org_id = m.org_id
|
||||
WHERE c.id = kanban_checklist_items.card_id
|
||||
AND m.user_id = auth.uid()
|
||||
)
|
||||
);
|
||||
|
||||
-- Create index for faster lookups
|
||||
CREATE INDEX IF NOT EXISTS idx_kanban_cards_assignee ON kanban_cards(assignee_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_kanban_cards_due_date ON kanban_cards(due_date);
|
||||
CREATE INDEX IF NOT EXISTS idx_checklist_items_card ON kanban_checklist_items(card_id);
|
||||
57
supabase/migrations/009_activity_tracking.sql
Normal file
57
supabase/migrations/009_activity_tracking.sql
Normal file
@@ -0,0 +1,57 @@
|
||||
-- Activity tracking for recent activity feed
|
||||
|
||||
CREATE TABLE IF NOT EXISTS activity_log (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
org_id UUID NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
|
||||
user_id UUID NOT NULL REFERENCES profiles(id) ON DELETE CASCADE,
|
||||
action TEXT NOT NULL, -- 'create', 'update', 'delete', 'move', 'assign', etc.
|
||||
entity_type TEXT NOT NULL, -- 'document', 'kanban_card', 'kanban_board', 'member', etc.
|
||||
entity_id UUID,
|
||||
entity_name TEXT,
|
||||
metadata JSONB DEFAULT '{}',
|
||||
created_at TIMESTAMPTZ DEFAULT now()
|
||||
);
|
||||
|
||||
-- Enable RLS
|
||||
ALTER TABLE activity_log ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
-- Users can view activity for orgs they belong to
|
||||
CREATE POLICY "Users can view org activity" ON activity_log
|
||||
FOR SELECT USING (
|
||||
EXISTS (
|
||||
SELECT 1 FROM org_members m
|
||||
WHERE m.org_id = activity_log.org_id
|
||||
AND m.user_id = auth.uid()
|
||||
)
|
||||
);
|
||||
|
||||
-- Users can insert their own activity
|
||||
CREATE POLICY "Users can insert own activity" ON activity_log
|
||||
FOR INSERT WITH CHECK (user_id = auth.uid());
|
||||
|
||||
-- Indexes for faster queries
|
||||
CREATE INDEX IF NOT EXISTS idx_activity_log_org ON activity_log(org_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_activity_log_created ON activity_log(created_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_activity_log_entity ON activity_log(entity_type, entity_id);
|
||||
|
||||
-- User preferences table for themes and settings
|
||||
CREATE TABLE IF NOT EXISTS user_preferences (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
user_id UUID NOT NULL REFERENCES profiles(id) ON DELETE CASCADE UNIQUE,
|
||||
theme TEXT DEFAULT 'dark' CHECK (theme IN ('dark', 'light', 'system')),
|
||||
accent_color TEXT DEFAULT '#00A3E0',
|
||||
use_org_theme BOOLEAN DEFAULT true, -- Whether org theme overrides user theme
|
||||
sidebar_collapsed BOOLEAN DEFAULT false,
|
||||
created_at TIMESTAMPTZ DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ DEFAULT now()
|
||||
);
|
||||
|
||||
-- Enable RLS
|
||||
ALTER TABLE user_preferences ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
-- Users can manage their own preferences
|
||||
CREATE POLICY "Users can manage own preferences" ON user_preferences
|
||||
FOR ALL USING (user_id = auth.uid());
|
||||
|
||||
-- Index
|
||||
CREATE INDEX IF NOT EXISTS idx_user_preferences_user ON user_preferences(user_id);
|
||||
Reference in New Issue
Block a user