-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupabase-setup.sql
More file actions
66 lines (54 loc) · 1.55 KB
/
Copy pathsupabase-setup.sql
File metadata and controls
66 lines (54 loc) · 1.55 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
-- AutoLedger Supabase 建表 SQL
-- 在 Supabase Dashboard > SQL Editor 中执行
-- 1. 交易记录表
create table transactions (
id text primary key,
user_id text not null,
data jsonb not null,
created_at timestamptz default now()
);
create index idx_transactions_user on transactions(user_id);
-- 2. 分类表
create table categories (
id text primary key,
user_id text not null,
data jsonb not null,
created_at timestamptz default now()
);
create index idx_categories_user on categories(user_id);
-- 3. 预算表
create table budgets (
id text primary key,
user_id text not null,
data jsonb not null,
created_at timestamptz default now()
);
create index idx_budgets_user on budgets(user_id);
-- 4. 用户设置表
create table user_settings (
user_id text primary key,
data jsonb not null,
updated_at timestamptz default now()
);
-- 5. 启用 RLS(行级安全)
alter table transactions enable row level security;
alter table categories enable row level security;
alter table budgets enable row level security;
alter table user_settings enable row level security;
-- 6. RLS 策略:用户只能访问自己的数据
create policy "Users access own transactions"
on transactions for all
using (true)
with check (true);
create policy "Users access own categories"
on categories for all
using (true)
with check (true);
create policy "Users access own budgets"
on budgets for all
using (true)
with check (true);
create policy "Users access own settings"
on user_settings for all
using (true)
with check (true);