-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Formatted with vscode extension `inferrinizzard.prettier-sql-vscode`.
- Loading branch information
1 parent
068daee
commit 41923ee
Showing
3 changed files
with
194 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,158 @@ | ||
-- name: CreateResource :exec | ||
INSERT INTO resource (uuid, title, content_md, image_url, resource_type, created_at, updated_at,deleted_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?); | ||
INSERT INTO | ||
resource ( | ||
uuid, | ||
title, | ||
content_md, | ||
image_url, | ||
resource_type, | ||
created_at, | ||
updated_at, | ||
deleted_at | ||
) | ||
VALUES | ||
(?, ?, ?, ?, ?, ?, ?, ?); | ||
|
||
-- name: CreateEvent :exec | ||
INSERT INTO event (uuid, location, start_at, end_at, is_all_day, host, visibility) VALUES (?, ?, ?, ?, ?, ?, ?); | ||
INSERT INTO | ||
event ( | ||
uuid, | ||
location, | ||
start_at, | ||
end_at, | ||
is_all_day, | ||
host, | ||
visibility | ||
) | ||
VALUES | ||
(?, ?, ?, ?, ?, ?, ?); | ||
|
||
-- name: CreatePerson :exec | ||
INSERT INTO person (uuid, name, preferred_pronoun) VALUES (?, ?, ?); | ||
INSERT INTO | ||
person (uuid, name, preferred_pronoun) | ||
VALUES | ||
(?, ?, ?); | ||
|
||
-- name: CreateResourceGroupMapping :exec | ||
INSERT INTO resource_id_group_id_mapping (resource_uuid, group_uuid, type, created_at, updated_at, deleted_at) VALUES (?, ?, ?, ?, ?, ?); | ||
INSERT INTO | ||
resource_id_group_id_mapping ( | ||
resource_uuid, | ||
group_uuid, | ||
type, | ||
created_at, | ||
updated_at, | ||
deleted_at | ||
) | ||
VALUES | ||
(?, ?, ?, ?, ?, ?); | ||
|
||
-- name: CreateGroupResourceMapping :exec | ||
INSERT INTO group_id_resource_list_mapping (group_uuid, resource_uuid, index_in_list, created_at, updated_at, deleted_at) VALUES (?, ?, ?, ?, ?, ?); | ||
INSERT INTO | ||
group_id_resource_list_mapping ( | ||
group_uuid, | ||
resource_uuid, | ||
index_in_list, | ||
created_at, | ||
updated_at, | ||
deleted_at | ||
) | ||
VALUES | ||
(?, ?, ?, ?, ?, ?); | ||
|
||
-- name: CreateAnnouncement :exec | ||
INSERT INTO announcement (uuid, event_groups_group_uuid, approved_by_list_uuid, visibility, announce_at, discord_channel_id, discord_message_id) VALUES (?, ?, ?, ?, ?, ?, ?); | ||
INSERT INTO | ||
announcement ( | ||
uuid, | ||
event_groups_group_uuid, | ||
approved_by_list_uuid, | ||
visibility, | ||
announce_at, | ||
discord_channel_id, | ||
discord_message_id | ||
) | ||
VALUES | ||
(?, ?, ?, ?, ?, ?, ?); | ||
|
||
-- name: DeleteResource :exec | ||
DELETE FROM resource WHERE id = ?; | ||
DELETE FROM resource | ||
WHERE | ||
id = ?; | ||
|
||
-- name: GetResource :exec | ||
SELECT uuid, title, content_md, image_url, resource_type, created_at, updated_at,deleted_at from resource where uuid = ?; | ||
SELECT | ||
uuid, | ||
title, | ||
content_md, | ||
image_url, | ||
resource_type, | ||
created_at, | ||
updated_at, | ||
deleted_at | ||
from | ||
resource | ||
where | ||
uuid = ?; | ||
|
||
-- name: GetEvent :exec | ||
SELECT uuid, location, start_at, end_at, is_all_day, host, visibility from event where uuid = ?; | ||
SELECT | ||
uuid, | ||
location, | ||
start_at, | ||
end_at, | ||
is_all_day, | ||
host, | ||
visibility | ||
from | ||
event | ||
where | ||
uuid = ?; | ||
|
||
-- name: GetPerson :exec | ||
SELECT uuid, name, preferred_pronoun from person where uuid = ?; | ||
SELECT | ||
uuid, | ||
name, | ||
preferred_pronoun | ||
from | ||
person | ||
where | ||
uuid = ?; | ||
|
||
-- name: GetResourceGroupMapping :exec | ||
SELECT resource_uuid, group_uuid, type, created_at, updated_at, deleted_at from resource_id_group_id_mapping where resource_uuid = ?; | ||
SELECT | ||
resource_uuid, | ||
group_uuid, | ||
type, | ||
created_at, | ||
updated_at, | ||
deleted_at | ||
from | ||
resource_id_group_id_mapping | ||
where | ||
resource_uuid = ?; | ||
|
||
-- name: GetGroupResourceMapping :exec | ||
SELECT group_uuid, resource_uuid, index_in_list, created_at, updated_at, deleted_at from group_id_resource_list_mapping where group_uuid = ?; | ||
SELECT | ||
group_uuid, | ||
resource_uuid, | ||
index_in_list, | ||
created_at, | ||
updated_at, | ||
deleted_at | ||
from | ||
group_id_resource_list_mapping | ||
where | ||
group_uuid = ?; | ||
|
||
-- name: GetAnnouncement :exec | ||
SELECT uuid, event_groups_group_uuid, approved_by_list_uuid, visibility, announce_at, discord_channel_id, discord_message_id from announcements where uuid = ?; | ||
SELECT | ||
uuid, | ||
event_groups_group_uuid, | ||
approved_by_list_uuid, | ||
visibility, | ||
announce_at, | ||
discord_channel_id, | ||
discord_message_id | ||
from | ||
announcements | ||
where | ||
uuid = ?; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,65 @@ | ||
-- Language: sqlite | ||
|
||
-- Create the 'resource_mapping' table. | ||
CREATE TABLE IF NOT EXISTS resource_id_group_id_mapping ( | ||
resource_uuid TEXT REFERENCES resource(uuid), | ||
group_uuid TEXT NOT NULL REFERENCES group_resource_list_mapping(uuid), | ||
type TEXT, | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
deleted_at TIMESTAMP DEFAULT NULL, | ||
); | ||
CREATE TABLE | ||
IF NOT EXISTS resource_id_group_id_mapping ( | ||
resource_uuid TEXT REFERENCES resource (uuid), | ||
group_uuid TEXT NOT NULL REFERENCES group_resource_list_mapping (uuid), | ||
type TEXT, | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
deleted_at TIMESTAMP DEFAULT NULL, | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS group_id_resource_list_mapping ( | ||
group_uuid TEXT, | ||
resource_uuid TEXT NOT NULL REFERENCES resource(uuid), | ||
index_in_list INTEGER NOT NULL, | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
deleted_at TIMESTAMP DEFAULT NULL, | ||
); | ||
CREATE TABLE | ||
IF NOT EXISTS group_id_resource_list_mapping ( | ||
group_uuid TEXT, | ||
resource_uuid TEXT NOT NULL REFERENCES resource (uuid), | ||
index_in_list INTEGER NOT NULL, | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
deleted_at TIMESTAMP DEFAULT NULL, | ||
); | ||
|
||
-- Create the 'resource' table. | ||
CREATE TABLE IF NOT EXISTS resource ( | ||
uuid TEXT PRIMARY KEY, | ||
title TEXT NOT NULL, | ||
content_md TEXT NOT NULL, | ||
image_url TEXT, | ||
resource_type TEXT NOT NULL, | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
deleted_at TIMESTAMP DEFAULT NULL, | ||
); | ||
CREATE TABLE | ||
IF NOT EXISTS resource ( | ||
uuid TEXT PRIMARY KEY, | ||
title TEXT NOT NULL, | ||
content_md TEXT NOT NULL, | ||
image_url TEXT, | ||
resource_type TEXT NOT NULL, | ||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
deleted_at TIMESTAMP DEFAULT NULL, | ||
); | ||
|
||
-- Create the 'events' table which is a table of event resources. | ||
CREATE TABLE IF NOT EXISTS event ( | ||
uuid TEXT PRIMARY KEY REFERENCES resource(uuid), | ||
location TEXT NOT NULL, | ||
start_at NUMBER NOT NULL, -- Start time in UTC milliseconds. | ||
end_at NUMBER NOT NULL, | ||
is_all_day BOOLEAN NOT NULL, | ||
host TEXT NOT NULL, -- Accepts team ID or plain text. | ||
visibility TEXT NOT NULL, -- Accepts 'public' or 'private'. | ||
) | ||
|
||
-- Create the 'person' table which is a table of person resources. | ||
CREATE TABLE IF NOT EXISTS person ( | ||
uuid TEXT REFERENCES resource(uuid), | ||
name TEXT, | ||
preferred_pronoun TEXT | ||
) | ||
|
||
-- Create the 'announcement' table which is a table of announcement resources. | ||
CREATE TABLE IF NOT EXISTS announcement ( | ||
uuid TEXT PRIMARY KEY REFERENCES resource(uuid), | ||
event_groups_group_uuid TEXT REFERENCES resource_group_mapping(resource_uuid), | ||
approved_by_list_uuid TEXT REFERENCES group_id_resource_list_mapping(uuid), | ||
visibility TEXT NOT NULL, -- Accepts 'public' or 'private'. | ||
announce_at INTEGER NOT NULL, -- UTC milliseconds. | ||
discord_channel_id TEXT, -- Discord channel ID. | ||
discord_message_id TEXT, -- Discord message ID. If present, the announcement has been posted. | ||
UNIQUE (id) | ||
) | ||
|
||
|
||
CREATE TABLE | ||
IF NOT EXISTS event ( | ||
uuid TEXT PRIMARY KEY REFERENCES resource (uuid), | ||
location TEXT NOT NULL, | ||
start_at NUMBER NOT NULL, -- Start time in UTC milliseconds. | ||
end_at NUMBER NOT NULL, | ||
is_all_day BOOLEAN NOT NULL, | ||
host TEXT NOT NULL, -- Accepts team ID or plain text. | ||
visibility TEXT NOT NULL, -- Accepts 'public' or 'private'. | ||
) | ||
-- Create the 'person' table which is a table of person resources. | ||
CREATE TABLE | ||
IF NOT EXISTS person ( | ||
uuid TEXT REFERENCES resource (uuid), | ||
name TEXT, | ||
preferred_pronoun TEXT | ||
) | ||
-- Create the 'announcement' table which is a table of announcement resources. | ||
CREATE TABLE | ||
IF NOT EXISTS announcement ( | ||
uuid TEXT PRIMARY KEY REFERENCES resource (uuid), | ||
event_groups_group_uuid TEXT REFERENCES resource_group_mapping (resource_uuid), | ||
approved_by_list_uuid TEXT REFERENCES group_id_resource_list_mapping (uuid), | ||
visibility TEXT NOT NULL, -- Accepts 'public' or 'private'. | ||
announce_at INTEGER NOT NULL, -- UTC milliseconds. | ||
discord_channel_id TEXT, -- Discord channel ID. | ||
discord_message_id TEXT, -- Discord message ID. If present, the announcement has been posted. | ||
UNIQUE (id) | ||
) |