-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupabase-complete-setup.sql
More file actions
100 lines (85 loc) · 2.6 KB
/
supabase-complete-setup.sql
File metadata and controls
100 lines (85 loc) · 2.6 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
-- =====================================================
-- COMPLETE SUPABASE SETUP (For Fresh Installation Only)
-- WARNING: This script drops existing tables!
-- Only use this on a NEW Supabase project
-- =====================================================
drop table if exists public.queries;
drop table if exists public.job_audit;
drop table if exists public.jobs;
-- =====================================================
-- JOBS TABLE
-- =====================================================
create table public.jobs (
id text primary key,
category text not null,
customer_name text not null,
phone_number text not null,
address text,
invoice_number text,
quote_number text,
importance text not null,
description text not null,
date text not null,
estimated_dispatch_date text,
items jsonb not null,
status text not null,
measurements jsonb,
attachments jsonb,
updated_at timestamptz,
completed_at timestamptz,
is_deleted boolean default false,
deleted_at timestamptz,
is_archived boolean default false,
archived_at timestamptz
);
alter table public.jobs replica identity full;
alter table public.jobs enable row level security;
create policy "public jobs read/write"
on public.jobs
for all
using (true)
with check (true);
-- =====================================================
-- JOB AUDIT TABLE
-- =====================================================
create table public.job_audit (
id text primary key,
job_id text,
action text not null,
timestamp timestamptz not null,
summary text not null,
client_id text
);
alter table public.job_audit replica identity full;
alter table public.job_audit enable row level security;
create policy "public audit read/write"
on public.job_audit
for all
using (true)
with check (true);
-- =====================================================
-- QUERIES TABLE (NEW)
-- =====================================================
create table public.queries (
id text primary key,
customer_name text not null,
phone_number text not null,
description text not null,
items jsonb default '[]'::jsonb,
date text not null,
updated_at timestamptz,
is_deleted boolean default false,
deleted_at timestamptz
);
alter table public.queries replica identity full;
alter table public.queries enable row level security;
create policy "public queries read/write"
on public.queries
for all
using (true)
with check (true);
-- =====================================================
-- VERIFICATION
-- =====================================================
-- List all tables
SELECT tablename FROM pg_tables WHERE schemaname = 'public' ORDER BY tablename;