mirror of
https://github.com/CompassConnections/Compass.git
synced 2025-12-30 17:38:55 -05:00
27 lines
743 B
SQL
27 lines
743 B
SQL
CREATE TABLE IF NOT EXISTS votes (
|
|
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
created_time TIMESTAMPTZ DEFAULT now() NOT NULL,
|
|
creator_id TEXT NOT NULL,
|
|
title TEXT NOT NULL,
|
|
is_anonymous BOOLEAN NOT NULL,
|
|
description JSONB,
|
|
status TEXT
|
|
);
|
|
|
|
-- Foreign Keys
|
|
alter table votes
|
|
add constraint votes_creator_id_fkey foreign key (creator_id) references users (id);
|
|
|
|
-- Row Level Security
|
|
ALTER TABLE votes ENABLE ROW LEVEL SECURITY;
|
|
|
|
-- Policies
|
|
DROP POLICY IF EXISTS "public read" ON votes;
|
|
CREATE POLICY "public read" ON votes
|
|
FOR SELECT USING (true);
|
|
|
|
-- Indexes
|
|
CREATE INDEX IF NOT EXISTS creator_id_idx ON votes (creator_id);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_votes_created_time ON votes (created_time DESC);
|