chore: supabase CLI setup, migrations, type regeneration - Install supabase CLI as dev dependency - Fix migration 023: use gen_random_uuid() instead of uuid_generate_v4() - Push migrations 023 + 024 to remote Supabase - Regenerate TypeScript types from live DB schema - Remove all (supabase as any) workaround casts across 6 files - Add convenience type aliases to generated types file - Align EventMember/EventRole/EventDepartment interfaces with DB nullability - Add npm scripts: db:push, db:types, db:migrate - svelte-check: 0 errors, vitest: 112/112 passed

This commit is contained in:
AlacrisDevs
2026-02-07 13:05:47 +02:00
parent d304129e5c
commit 202f0fe9a1
10 changed files with 368 additions and 76 deletions

View File

@@ -49,7 +49,7 @@ export const load: LayoutServerLoad = async ({ params, locals }) => {
.eq('org_id', org.id)
.order('created_at', { ascending: false })
.limit(10),
(locals.supabase as any)
locals.supabase
.from('profiles')
.select('id, email, full_name, avatar_url, phone, discord_handle, shirt_size, hoodie_size')
.eq('id', user.id)
@@ -111,13 +111,13 @@ export const load: LayoutServerLoad = async ({ params, locals }) => {
let memberProfilesMap: Record<string, { id: string; email: string; full_name: string | null; avatar_url: string | null; phone: string | null; discord_handle: string | null; shirt_size: string | null; hoodie_size: string | null }> = {};
if (memberUserIds.length > 0) {
const { data: memberProfiles } = await (locals.supabase as any)
const { data: memberProfiles } = await locals.supabase
.from('profiles')
.select('id, email, full_name, avatar_url, phone, discord_handle, shirt_size, hoodie_size')
.in('id', memberUserIds);
if (memberProfiles) {
memberProfilesMap = Object.fromEntries(memberProfiles.map((p: any) => [p.id, p]));
memberProfilesMap = Object.fromEntries(memberProfiles.map(p => [p.id, p]));
}
}

View File

@@ -175,7 +175,7 @@
async function saveProfile() {
isSaving = true;
const { error } = await (supabase as any)
const { error } = await supabase
.from("profiles")
.update({
full_name: fullName || null,

View File

@@ -72,7 +72,7 @@
if (!newEventName.trim()) return;
creating = true;
try {
const { data: created, error } = await (supabase as any)
const { data: created, error } = await supabase
.from("events")
.insert({
org_id: data.org.id,

View File

@@ -151,7 +151,7 @@
async function handleSave() {
saving = true;
try {
const { error } = await (supabase as any)
const { error } = await supabase
.from("events")
.update({
name: editName.trim(),
@@ -183,7 +183,7 @@
async function handleDelete() {
deleting = true;
try {
const { error } = await (supabase as any)
const { error } = await supabase
.from("events")
.delete()
.eq("id", data.event.id);

View File

@@ -141,7 +141,7 @@
if (!selectedUserId) return;
adding = true;
try {
const { data: inserted, error } = await (supabase as any)
const { data: inserted, error } = await supabase
.from("event_members")
.upsert(
{
@@ -159,7 +159,7 @@
// Assign departments
for (const deptId of selectedDeptIds) {
await (supabase as any)
await supabase
.from("event_member_departments")
.upsert(
{ event_member_id: inserted.id, department_id: deptId },
@@ -209,7 +209,7 @@
updatingMember = true;
try {
// Update member record
const { error } = await (supabase as any)
const { error } = await supabase
.from("event_members")
.update({
role_id: editRoleId || null,
@@ -224,14 +224,14 @@
const toAdd = editDeptIds.filter((id) => !oldDeptIds.includes(id));
for (const deptId of toRemove) {
await (supabase as any)
await supabase
.from("event_member_departments")
.delete()
.eq("event_member_id", editingMember.id)
.eq("department_id", deptId);
}
for (const deptId of toAdd) {
await (supabase as any)
await supabase
.from("event_member_departments")
.upsert(
{ event_member_id: editingMember.id, department_id: deptId },
@@ -268,7 +268,7 @@
if (!memberToRemove) return;
removing = true;
try {
const { error } = await (supabase as any)
const { error } = await supabase
.from("event_members")
.delete()
.eq("id", memberToRemove.id);
@@ -298,7 +298,7 @@
savingDept = true;
try {
if (editingDept) {
const { data: updated, error } = await (supabase as any)
const { data: updated, error } = await supabase
.from("event_departments")
.update({ name: deptName.trim(), color: deptColor })
.eq("id", editingDept.id)
@@ -310,7 +310,7 @@
);
toasts.success(m.team_dept_updated());
} else {
const { data: created, error } = await (supabase as any)
const { data: created, error } = await supabase
.from("event_departments")
.insert({
event_id: data.event.id,
@@ -334,7 +334,7 @@
async function handleDeleteDept(dept: EventDepartment) {
try {
const { error } = await (supabase as any)
const { error } = await supabase
.from("event_departments")
.delete()
.eq("id", dept.id);
@@ -364,7 +364,7 @@
savingRole = true;
try {
if (editingRole) {
const { data: updated, error } = await (supabase as any)
const { data: updated, error } = await supabase
.from("event_roles")
.update({ name: roleName.trim(), color: roleColor })
.eq("id", editingRole.id)
@@ -376,7 +376,7 @@
);
toasts.success(m.team_role_updated());
} else {
const { data: created, error } = await (supabase as any)
const { data: created, error } = await supabase
.from("event_roles")
.insert({
event_id: data.event.id,
@@ -400,7 +400,7 @@
async function handleDeleteRole(role: EventRole) {
try {
const { error } = await (supabase as any)
const { error } = await supabase
.from("event_roles")
.delete()
.eq("id", role.id);