2
อัปเดต SQL (รันใน Supabase SQL Editor)
รัน SQL นี้เพื่อเพิ่มฟิลด์ใหม่และสร้างตาราง guild_members:
-- ═══ รัน SQL นี้ใน Supabase SQL Editor ═══
-- 1) เพิ่มฟิลด์ใหม่ (ถ้ายังไม่มี)
alter table war_records
add column if not exists job_class text default '',
add column if not exists field_type text default 'สนามหลัก',
add column if not exists rate_points int4 default 0,
add column if not exists defeat int4 default 0,
add column if not exists defeat_points int4 default 0,
add column if not exists assist_points int4 default 0,
add column if not exists death_points int4 default 0,
add column if not exists control_points int4 default 0,
add column if not exists dmg_taken int8 default 0,
add column if not exists node_s int4 default 0,
add column if not exists node_a int4 default 0,
add column if not exists node_b int4 default 0;
-- 2) เปลี่ยน damage / healing / score / kill → int8
-- (int4 รองรับสูงสุด ~2.1 พันล้าน, int8 รองรับ ~9.2 ล้านล้านล้าน)
alter table war_records
alter column damage type int8 using damage::int8,
alter column healing type int8 using healing::int8,
alter column score type int8 using score::int8,
alter column kill type int8 using kill::int8;
-- 3) สร้างตาราง char_profiles (เก็บ Profile ตัวละคร)
create table if not exists char_profiles (
char_name text primary key,
job_class text,
hp text, sp text, patk text, pdef text, matk text, mdef text,
rpatk text, rpdef text, rmatk text, rmdef text,
hprec text, sprec text, hit text, flee text,
aspd text, mspd text, vct text, vctp text, fct text, fctp text,
healeff text, healrec text, crit text, critres text,
critdmg text, critdmgres text,
pdmgp text, pdmgred text, mdmgp text, mdmgred text,
ipdeff text, ipdefp text, imdeff text, imdefp text,
pdmgf text, mdmgf text,
pvered text, pvebonus text, pvpred text, pvpbonus text,
updated_at timestamptz default now()
);
alter table char_profiles enable row level security;
create policy "allow_all_profiles" on char_profiles
for all using (true) with check (true);
-- 4) สร้างตาราง guild_members (ถ้ายังไม่มี)
create table if not exists guild_members (
id uuid default gen_random_uuid() primary key,
created_at timestamptz default now(),
char_name text not null unique,
job_class text not null
);
alter table guild_members enable row level security;
create policy "allow_all_members" on guild_members
for all using (true) with check (true);
3
📦 สร้าง Storage Bucket (เก็บรูป Screenshot)
ไปที่ Supabase → Storage → New bucket
ตั้งชื่อ bucket: war-screenshots และเปิด Public bucket
จากนั้นรัน SQL นี้เพื่อเปิดสิทธิ์ upload:
-- เปิดสิทธิ์ Storage สำหรับ war-screenshots
create policy "allow_upload" on storage.objects
for insert with check (bucket_id = 'war-screenshots');
create policy "allow_select" on storage.objects
for select using (bucket_id = 'war-screenshots');
create policy "allow_delete" on storage.objects
for delete using (bucket_id = 'war-screenshots');