Rename love_stars

This commit is contained in:
MartinBraquet
2025-10-20 16:03:28 +02:00
parent e06a382c94
commit 4876ca2643
6 changed files with 28 additions and 28 deletions

View File

@@ -14,7 +14,7 @@ export const starProfile: APIHandler<'star-profile'> = async (props, auth) => {
if (remove) {
const { error } = await tryCatch(
pg.none(
'delete from love_stars where creator_id = $1 and target_id = $2',
'delete from profile_stars where creator_id = $1 and target_id = $2',
[creatorId, targetUserId]
)
)
@@ -27,8 +27,8 @@ export const starProfile: APIHandler<'star-profile'> = async (props, auth) => {
// Check if star already exists
const { data: existing } = await tryCatch(
pg.oneOrNone<Row<'love_stars'>>(
'select * from love_stars where creator_id = $1 and target_id = $2',
pg.oneOrNone<Row<'profile_stars'>>(
'select * from profile_stars where creator_id = $1 and target_id = $2',
[creatorId, targetUserId]
)
)
@@ -40,7 +40,7 @@ export const starProfile: APIHandler<'star-profile'> = async (props, auth) => {
// Insert the new star
const { error } = await tryCatch(
insert(pg, 'love_stars', { creator_id: creatorId, target_id: targetUserId })
insert(pg, 'profile_stars', { creator_id: creatorId, target_id: targetUserId })
)
if (error) {

View File

@@ -1,21 +0,0 @@
CREATE TABLE IF NOT EXISTS love_stars (
created_time TIMESTAMPTZ DEFAULT now() NOT NULL,
creator_id TEXT NOT NULL,
star_id TEXT DEFAULT random_alphanumeric(12) NOT NULL,
target_id TEXT NOT NULL,
CONSTRAINT love_stars_pkey PRIMARY KEY (creator_id, star_id)
);
-- Row Level Security
ALTER TABLE love_stars ENABLE ROW LEVEL SECURITY;
-- Policies
DROP POLICY IF EXISTS "public read" ON love_stars;
CREATE POLICY "public read" ON love_stars
FOR SELECT USING (true);
-- Indexes
-- The primary key already creates a unique index on (creator_id, star_id), so no need to recreate it.
DROP INDEX IF EXISTS love_stars_target_id_idx;
CREATE INDEX love_stars_target_id_idx ON public.love_stars USING btree (target_id);

View File

@@ -14,7 +14,7 @@ BEGIN;
\i backend/supabase/profile_likes.sql
\i backend/supabase/compatibility_prompts.sql
\i backend/supabase/profile_ships.sql
\i backend/supabase/love_stars.sql
\i backend/supabase/profile_stars.sql
\i backend/supabase/love_waitlist.sql
\i backend/supabase/user_events.sql
\i backend/supabase/user_notifications.sql

View File

@@ -0,0 +1,21 @@
CREATE TABLE IF NOT EXISTS profile_stars (
created_time TIMESTAMPTZ DEFAULT now() NOT NULL,
creator_id TEXT NOT NULL,
star_id TEXT DEFAULT random_alphanumeric(12) NOT NULL,
target_id TEXT NOT NULL,
CONSTRAINT profile_stars_pkey PRIMARY KEY (creator_id, star_id)
);
-- Row Level Security
ALTER TABLE profile_stars ENABLE ROW LEVEL SECURITY;
-- Policies
DROP POLICY IF EXISTS "public read" ON profile_stars;
CREATE POLICY "public read" ON profile_stars
FOR SELECT USING (true);
-- Indexes
-- The primary key already creates a unique index on (creator_id, star_id), so no need to recreate it.
DROP INDEX IF EXISTS profile_stars_target_id_idx;
CREATE INDEX profile_stars_target_id_idx ON public.profile_stars USING btree (target_id);

View File

@@ -211,7 +211,7 @@ export type Database = {
}
Relationships: []
}
love_stars: {
profile_stars: {
Row: {
created_time: string
creator_id: string

View File

@@ -5,7 +5,7 @@ import {DisplayUser} from "common/api/user-types";
export const getStars = async (creatorId: string) => {
const { data } = await run(
db
.from('love_stars')
.from('profile_stars')
.select('*')
.filter('creator_id', 'eq', creatorId)
.order('created_time', { ascending: false })