forked from powersync-ja/powersync-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.sql
36 lines (30 loc) · 1.08 KB
/
database.sql
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
-- Create pebbles table
create table
public.pebbles (
id uuid not null default gen_random_uuid (),
created_at timestamp with time zone not null default now(),
shape text not null,
user_id uuid null,
constraint pebbles_pkey primary key (id)
) tablespace pg_default;
-- Setup RLS for table
alter table public.pebbles enable row level security;
create policy "owned pebbles" on "public"."pebbles" for ALL using (
(auth.uid() = user_id)
);
-- Create publication for powersync
create publication powersync for table public.pebbles;
-- Create operations table, used for telemetry. This table doesn't need to be synced to the device.
create table
public.operations (
id uuid not null default gen_random_uuid (),
created_at timestamp with time zone not null default now(),
operation text not null,
user_id uuid null,
constraint operations_pkey primary key (id)
) tablespace pg_default;
-- Setup RLS for table
alter table public.operations enable row level security;
create policy "user operations" on "public"."operations" for ALL using (
(auth.uid() = user_id)
);