-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathADD_VOTERS_TABLE.sql
More file actions
37 lines (31 loc) · 1.24 KB
/
ADD_VOTERS_TABLE.sql
File metadata and controls
37 lines (31 loc) · 1.24 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
27
28
29
30
31
32
33
34
35
36
37
-- Add Voters Table to Supabase for DNM Dashboard
-- Run this in your Supabase SQL Editor
-- Create voters table
CREATE TABLE IF NOT EXISTS voters (
id BIGSERIAL PRIMARY KEY,
name TEXT NOT NULL,
gender TEXT,
dob TEXT,
age INTEGER,
village TEXT,
polling_station TEXT,
parish TEXT,
division TEXT,
created_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(name, dob, polling_station)
);
-- Create indexes for faster searches
CREATE INDEX IF NOT EXISTS idx_voters_name ON voters(name);
CREATE INDEX IF NOT EXISTS idx_voters_polling_station ON voters(polling_station);
CREATE INDEX IF NOT EXISTS idx_voters_village ON voters(village);
CREATE INDEX IF NOT EXISTS idx_voters_division ON voters(division);
CREATE INDEX IF NOT EXISTS idx_voters_parish ON voters(parish);
-- Create text search index for name search
CREATE INDEX IF NOT EXISTS idx_voters_name_search ON voters USING gin(to_tsvector('english', name));
-- Disable RLS for easy access
ALTER TABLE voters DISABLE ROW LEVEL SECURITY;
-- Grant access
GRANT ALL ON voters TO anon, authenticated;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO anon, authenticated;
-- Success message
SELECT '✅ Voters table created successfully! Ready to upload voter data.' as message;