-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigration.sql
More file actions
26 lines (21 loc) · 1.36 KB
/
migration.sql
File metadata and controls
26 lines (21 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
-- ═══════════════════════════════════════════
-- VERD Database Migration (V2)
-- ═══════════════════════════════════════════
-- 1. Update Profiles table to include location
ALTER TABLE public.profiles
ADD COLUMN IF NOT EXISTS location TEXT;
-- 2. Ensure scans table has created_at (fixes "column does not exist" issue)
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name='scans' AND column_name='created_at') THEN
ALTER TABLE public.scans ADD COLUMN created_at TIMESTAMPTZ DEFAULT NOW();
END IF;
END $$;
-- 3. Add index for faster scan lookups
CREATE INDEX IF NOT EXISTS scans_user_id_idx ON public.scans (user_id);
CREATE INDEX IF NOT EXISTS scans_created_at_idx ON public.scans (created_at DESC);
-- 4. Correct any missing descriptions in plant_diseases
UPDATE public.plant_diseases SET description = 'No detailed description available yet.' WHERE description IS NULL;
-- ═══════════════════════════════════════════
-- Migration Complete
-- ═══════════════════════════════════════════