mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-01-06 04:48:14 -05:00
26 lines
935 B
SQL
26 lines
935 B
SQL
CREATE TABLE IF NOT EXISTS love_ships (
|
|
created_time TIMESTAMPTZ DEFAULT now() NOT NULL,
|
|
creator_id TEXT NOT NULL,
|
|
ship_id TEXT DEFAULT random_alphanumeric(12) NOT NULL,
|
|
target1_id TEXT NOT NULL,
|
|
target2_id TEXT NOT NULL,
|
|
CONSTRAINT love_ships_pkey PRIMARY KEY (creator_id, ship_id)
|
|
);
|
|
|
|
-- Row Level Security
|
|
ALTER TABLE love_ships ENABLE ROW LEVEL SECURITY;
|
|
|
|
-- Policies
|
|
DROP POLICY IF EXISTS "public read" ON love_ships;
|
|
CREATE POLICY "public read" ON love_ships
|
|
FOR SELECT USING (true);
|
|
|
|
-- Indexes
|
|
-- Primary key automatically creates a unique index on (creator_id, ship_id), so no need to recreate it.
|
|
-- Keep additional indexes for query optimization:
|
|
DROP INDEX IF EXISTS love_ships_target1_id;
|
|
CREATE INDEX love_ships_target1_id ON public.love_ships USING btree (target1_id);
|
|
|
|
DROP INDEX IF EXISTS love_ships_target2_id;
|
|
CREATE INDEX love_ships_target2_id ON public.love_ships USING btree (target2_id);
|