-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
164 lines (148 loc) · 5.83 KB
/
Copy pathschema.sql
File metadata and controls
164 lines (148 loc) · 5.83 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
-- E7 Orbit maintained hero catalog.
-- Run this in Supabase SQL Editor before importing data.
-- The Android app only needs the publishable/anon key and read access.
create table if not exists public.hero_catalog (
code text primary key,
name text not null,
rarity integer,
attribute text not null default '',
role text not null default '',
zodiac text,
description text,
awakenings jsonb not null default '[]'::jsonb,
memory_imprint jsonb not null default '{}'::jsonb,
icon_url text,
thumbnail_url text,
image_url text,
stats_attack integer,
stats_health integer,
stats_defense integer,
base_attack integer,
base_health integer,
stats_speed integer,
stats_critical_chance integer,
stats_critical_damage integer,
stats_effectiveness integer,
stats_effect_resistance integer,
stats_combat_power integer,
source text not null default 'community-import',
source_updated_at timestamptz,
updated_at timestamptz not null default now()
);
create table if not exists public.hero_skills (
hero_code text not null references public.hero_catalog(code) on delete cascade,
slot integer not null check (slot between 1 and 5), -- 1-3 base, 4-5 transformed/extra skills (e.g. Tamarinne)
name text not null default '',
icon_url text,
description text,
enhanced_description text,
cooldown integer,
soul_gain integer,
soul_requirement integer,
soul_description text,
attack_rate double precision,
pow double precision,
is_passive boolean not null default false,
can_enhance boolean not null default false,
values jsonb not null default '[]'::jsonb,
enhancements jsonb not null default '[]'::jsonb,
buff_slugs text[] not null default '{}',
debuff_slugs text[] not null default '{}',
source text not null default 'epic7db',
source_updated_at timestamptz,
updated_at timestamptz not null default now(),
primary key (hero_code, slot)
);
create index if not exists hero_skills_hero_code_idx on public.hero_skills(hero_code);
create table if not exists public.hero_exclusive_equipment (
code text primary key,
hero_code text not null unique references public.hero_catalog(code) on delete cascade,
name text not null check (length(trim(name)) > 0),
description text,
icon_url text not null check (length(trim(icon_url)) > 0),
stat_type text not null check (stat_type in (
'attack', 'health', 'defense', 'speed',
'critical_chance', 'critical_damage',
'effectiveness', 'effect_resistance'
)),
stat_min double precision not null,
stat_max double precision not null check (stat_max >= stat_min),
stat_percent boolean not null default false,
enhancements jsonb not null check (
case when jsonb_typeof(enhancements) = 'array'
then jsonb_array_length(enhancements) = 3
and enhancements @> '[{"option": 1}, {"option": 2}, {"option": 3}]'::jsonb
else false
end
),
source text not null default 'gamekee',
source_updated_at timestamptz,
updated_at timestamptz not null default now(),
check (code = 'ee-' || hero_code)
);
create index if not exists hero_exclusive_equipment_hero_code_idx
on public.hero_exclusive_equipment(hero_code);
create table if not exists public.status_effect_catalog (
slug text primary key,
label text not null,
description text,
icon_url text,
source text not null default 'gamedatabase',
source_updated_at timestamptz,
updated_at timestamptz not null default now()
);
create index if not exists hero_skills_buff_slugs_idx
on public.hero_skills using gin (buff_slugs);
create index if not exists hero_skills_debuff_slugs_idx
on public.hero_skills using gin (debuff_slugs);
alter table public.hero_catalog enable row level security;
alter table public.hero_skills enable row level security;
alter table public.hero_exclusive_equipment enable row level security;
alter table public.status_effect_catalog enable row level security;
drop policy if exists "Public can read hero catalog" on public.hero_catalog;
create policy "Public can read hero catalog"
on public.hero_catalog for select
to anon, authenticated
using (true);
drop policy if exists "Public can read hero skills" on public.hero_skills;
create policy "Public can read hero skills"
on public.hero_skills for select
to anon, authenticated
using (true);
drop policy if exists "Public can read hero exclusive equipment" on public.hero_exclusive_equipment;
create policy "Public can read hero exclusive equipment"
on public.hero_exclusive_equipment for select
to anon, authenticated
using (true);
drop policy if exists "Public can read status effect catalog" on public.status_effect_catalog;
create policy "Public can read status effect catalog"
on public.status_effect_catalog for select
to anon, authenticated
using (true);
create table if not exists public.artifact_catalog (
code text primary key,
name text not null,
rarity integer,
role text not null default '',
description text,
max_description text,
lore text,
image_url text,
icon_url text,
stats_attack integer,
stats_health integer,
stats_defense integer,
base_attack integer,
base_health integer,
source text not null default 'epic7db',
source_updated_at timestamptz,
updated_at timestamptz not null default now()
);
alter table public.artifact_catalog enable row level security;
drop policy if exists "Public can read artifact catalog" on public.artifact_catalog;
create policy "Public can read artifact catalog"
on public.artifact_catalog for select
to anon, authenticated
using (true);
-- The service_role key bypasses RLS for tools/sync-hero-catalog.mjs.
-- Do not create anonymous INSERT/UPDATE policies: mobile clients must be read-only.