mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-04-04 06:51:45 -04:00
Rename love_stars
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
@@ -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
|
||||
|
||||
21
backend/supabase/profile_stars.sql
Normal file
21
backend/supabase/profile_stars.sql
Normal 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);
|
||||
@@ -211,7 +211,7 @@ export type Database = {
|
||||
}
|
||||
Relationships: []
|
||||
}
|
||||
love_stars: {
|
||||
profile_stars: {
|
||||
Row: {
|
||||
created_time: string
|
||||
creator_id: string
|
||||
|
||||
@@ -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 })
|
||||
|
||||
Reference in New Issue
Block a user