23 lines
656 B
SQL
23 lines
656 B
SQL
CREATE TYPE event_type AS ENUM ('sports', 'meetings', 'drama', 'music', 'other');
|
|
|
|
CREATE TABLE events (
|
|
id SERIAL PRIMARY KEY,
|
|
description TEXT NOT NULL,
|
|
title VARCHAR(255) NOT NULL,
|
|
time_start TIMESTAMP NOT NULL,
|
|
time_end TIMESTAMP NOT NULL,
|
|
event_type event_type NOT NULL,
|
|
points INTEGER NOT NULL,
|
|
place VARCHAR(255),
|
|
price DECIMAL(10, 2) NOT NULL,
|
|
created_by INTEGER REFERENCES users(id)
|
|
);
|
|
|
|
CREATE TABLE event_attendees (
|
|
event_id INTEGER REFERENCES events(id),
|
|
user_id INTEGER REFERENCES users(id),
|
|
PRIMARY KEY (event_id, user_id)
|
|
);
|
|
|
|
CREATE INDEX idx_event_attendees ON event_attendees(event_id);
|