-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupabase-schema.sql
More file actions
37 lines (31 loc) · 1.12 KB
/
Copy pathsupabase-schema.sql
File metadata and controls
37 lines (31 loc) · 1.12 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
-- Run this in your Supabase SQL Editor
-- Dashboard → SQL Editor → New Query → paste and run
create table if not exists orders (
id bigserial primary key,
created_at timestamptz default now(),
order_type text not null check (order_type in ('delivery','pickup')),
items jsonb not null,
total numeric not null,
customer_name text not null,
customer_number text not null,
customer_address text,
payment_method text not null,
notes text,
status text not null default 'pending'
check (status in ('pending','preparing','ready','completed','cancelled'))
);
-- Allow anonymous inserts (customer orders)
alter table orders enable row level security;
create policy "Anyone can insert orders"
on orders for insert
with check (true);
-- Only authenticated (admin via service key or anon with policy) can read
create policy "Anyone can read orders"
on orders for select
using (true);
-- Allow updates (for status changes)
create policy "Anyone can update orders"
on orders for update
using (true);
-- Enable realtime
alter publication supabase_realtime add table orders;