feat: add db-seed to makefile and merge migrations

This commit is contained in:
Levente Orban
2025-11-10 09:59:44 +01:00
parent 5b7178bec1
commit 52d48e4839
4 changed files with 27 additions and 44 deletions

View File

@@ -19,7 +19,7 @@ CREATE TABLE IF NOT EXISTS events (
type VARCHAR(20) NOT NULL CHECK (type IN ('limited','unlimited')),
attendee_limit INTEGER CHECK (attendee_limit > 0),
user_id VARCHAR(100) NOT NULL,
visibility VARCHAR(20) NOT NULL DEFAULT 'public' CHECK (visibility IN ('public','private')),
visibility VARCHAR(20) NOT NULL DEFAULT 'public' CHECK (visibility IN ('public','private', 'invite-only')),
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
@@ -34,6 +34,15 @@ CREATE TABLE IF NOT EXISTS rsvps (
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- Invite tokens
CREATE TABLE IF NOT EXISTS invite_tokens (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
event_id VARCHAR(8) NOT NULL REFERENCES events(id) ON DELETE CASCADE,
token VARCHAR(32) NOT NULL UNIQUE,
expires_at TIMESTAMPTZ NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- =======================================
-- Indexes
-- =======================================
@@ -42,5 +51,9 @@ CREATE INDEX IF NOT EXISTS idx_events_date ON events(date);
CREATE INDEX IF NOT EXISTS idx_events_location_type ON events(location_type);
CREATE INDEX IF NOT EXISTS idx_rsvps_event_id ON rsvps(event_id);
CREATE INDEX IF NOT EXISTS idx_rsvps_user_id ON rsvps(user_id);
CREATE INDEX IF NOT EXISTS idx_invite_tokens_event_id ON invite_tokens(event_id);
CREATE INDEX IF NOT EXISTS idx_invite_tokens_token ON invite_tokens(token);
CREATE INDEX IF NOT EXISTS idx_invite_tokens_expires_at ON invite_tokens(expires_at);
COMMIT;