-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use ts_rs::TS; | ||
|
||
use crate::ID; | ||
|
||
/// Group of calendar events | ||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TS)] | ||
#[serde(rename_all = "camelCase")] | ||
#[ts(export)] | ||
pub struct EventGroup { | ||
pub id: ID, | ||
pub calendar_id: ID, | ||
pub parent_id: Option<String>, | ||
pub external_id: Option<String>, | ||
pub event_ids: Vec<ID>, | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
-- Create the `events_groups` table | ||
CREATE TABLE IF NOT EXISTS events_groups ( | ||
group_uid uuid PRIMARY KEY DEFAULT uuid_generate_v4() NOT NULL, | ||
calendar_uid uuid NOT NULL REFERENCES calendars(calendar_uid) ON DELETE CASCADE, | ||
/* | ||
parent_id is only useful for linking this event to an external object outside Nittei ecosystem | ||
it's indexed, it's not a foreign key, and it's a string as the external object's id can have any format | ||
*/ | ||
parent_id text, | ||
external_id text | ||
); | ||
|
||
-- Add the `group_id` column to the `calendar_events` table | ||
ALTER TABLE | ||
calendar_events | ||
ADD | ||
COLUMN IF NOT EXISTS group_uid uuid REFERENCES events_groups(group_uid) ON DELETE NO ACTION; | ||
|
||
-- Add a unique constraint on `external_id` in `events_groups` | ||
ALTER TABLE | ||
events_groups | ||
ADD | ||
CONSTRAINT events_groups__external_id__unique UNIQUE (external_id); | ||
|
||
-- Add an index on `parent_id` in `events_groups` | ||
CREATE INDEX IF NOT EXISTS events_groups__parent_id_idx ON events_groups (parent_id); | ||
|
||
-- Add an index on `group_id` in `calendar_events` | ||
CREATE INDEX IF NOT EXISTS calendar_events__group_uid_idx ON calendar_events (group_uid); |