more updates to MODELS and SCHEMA

This commit is contained in:
Sundog 2023-10-19 16:01:09 -04:00
parent 9c4d3a7197
commit 188544366c
2 changed files with 177 additions and 23 deletions

View File

@ -227,8 +227,8 @@ struct Album {
deleted_at: Option<chrono::DateTime>,
tags: Option<Vec<Tag>>,
comments: Option<Vec<Comment>>,
cover: Option<String>,
images: Option<Vec<String>>,
cover: Option<ImageId>,
images: Option<Vec<ImageId>>,
}
```
@ -247,9 +247,9 @@ struct Playlist {
created_by: PersonId,
created_at: chrono::DateTime,
modified_at: chrono::DateTime,
deleted_at: Option<chrono::DateTime>
deleted_at: Option<chrono::DateTime>,
is_public: bool,
cover: Option<String>,
cover: Option<ImageId>,
tracks: Vec<Track>,
tags: Option<Vec<Tag>>,
comments: Option<Vec<Comment>>,
@ -272,11 +272,12 @@ struct Article {
created_by: PersonId,
created_at: chrono::DateTime,
modified_at: chrono::DateTime,
deleted_at: Option<chrono::DateTime>
published_at: Option<chrono::DateTime>,
deleted_at: Option<chrono::DateTime>,
is_public: bool,
is_draft: bool,
cover: Option<String>,
images: Option<Vec<String>>,
cover: Option<ImageId>,
images: Option<Vec<ImageId>>,
tracks: Option<Vec<Track>>,
tags: Option<Vec<Tag>>,
comments: Option<Vec<Comment>>,
@ -336,11 +337,14 @@ struct ImageId {
}
struct Image {
id: ImageId,
name: Option<String>,
path: String,
url: String,
width: usize,
height: usize,
alt_text: String,
is_public: bool,
allow_hotlinking: bool,
created_by: PersonId,
created_at: chrono::DateTime,
modified_by: PersonId,

180
SCHEMA.md
View File

@ -212,6 +212,33 @@ CREATE INDEX Artists_is_enabled_IDX ON Artists (is_enabled);
CREATE INDEX Artists_is_public_IDX ON Artists (is_public);
```
# ArtistContacts
The ArtistContacts tablekey-value pairs of methods to contact representatives of the Artist (for example, "fediverse: sundog@toot-lab.reclaim.technology" or "email: sundog@reclaim.technology").
``` sql
CREATE TABLE ArtistContacts (
id TEXT(36),
artist_id TEXT(36),
"method" TEXT,
address TEXT,
created_by TEXT(36),
created_at INTEGER,
modified_by TEXT(36),
modified_at INTEGER,
deleted_by TEXT(36),
deleted_at INTEGER,
sort_order INTEGER,
CONSTRAINT ArtistContacts_PK PRIMARY KEY (id),
CONSTRAINT ArtistContacts_FK FOREIGN KEY (artist_id) REFERENCES Artists(id) ON DELETE CASCADE
CONSTRAINT ArtistContacts_FK_1 FOREIGN KEY (created_by) REFERENCES Persons(id),
CONSTRAINT ArtistContacts_FK_2 FOREIGN KEY (modified_by) REFERENCES Persons(id),
CONSTRAINT ArtistContacts_FK_3 FOREIGN KEY (deleted_by) REFERENCES Persons(id)
);
CREATE INDEX ArtistContacts_artist_id_IDX ON ArtistContacts (artist_id);
CREATE INDEX ArtistContacts_deleted_at_IDX ON ArtistContacts (deleted_at);
CREATE INDEX ArtistContacts_sort_order_IDX ON ArtistContacts (sort_order);
```
# ArtistTags
The ArtistTags table will contain Tags that have been assigned to an Artist.
@ -548,33 +575,156 @@ CREATE INDEX PlaylistComments_playlist_id_IDX ON PlaylistComments (playlist_id);
CREATE INDEX PlaylistComments_comment_id_IDX ON PlaylistComments (comment_id);
```
# Images
The Images table will contain Images!
``` sql
CREATE TABLE Images (
id TEXT(36),
name TEXT,
"path" TEXT,
url TEXT,
width INTEGER,
height INTEGER,
alt_text TEXT,
is_public INTEGER DEFAULT (1),
allow_hotlinking INTEGER DEFAULT (0),
created_by TEXT(36),
created_at INTEGER,
modified_by TEXT(36),
modified_at INTEGER,
deleted_by TEXT(36),
deleted_at INTEGER,
CONSTRAINT Images_PK PRIMARY KEY (id),
CONSTRAINT Images_FK FOREIGN KEY (created_by) REFERENCES Persons(id),
CONSTRAINT Images_FK_1 FOREIGN KEY (modified_by) REFERENCES Persons(id),
CONSTRAINT Images_FK_2 FOREIGN KEY (deleted_by) REFERENCES Persons(id)
);
CREATE INDEX Images_name_IDX ON Images (name);
CREATE INDEX Images_path_IDX ON Images ("path");
CREATE INDEX Images_url_IDX ON Images (url);
CREATE INDEX Images_alt_text_IDX ON Images (alt_text);
CREATE INDEX Images_is_public_IDX ON Images (is_public);
CREATE INDEX Images_allow_hotlinking_IDX ON Images (allow_hotlinking);
CREATE INDEX Images_created_by_IDX ON Images (created_by);
CREATE INDEX Images_deleted_at_IDX ON Images (deleted_at);
```
# Videos
The Videos table will contain Videos!
``` sql
CREATE TABLE Videos (
id TEXT(36),
name TEXT,
"path" TEXT,
url TEXT,
width INTEGER,
height INTEGER,
duration NUMERIC,
alt_text TEXT,
is_public INTEGER DEFAULT (1),
allow_hotlinking INTEGER DEFAULT (0),
created_by TEXT(36),
created_at INTEGER,
modified_by TEXT(36),
modified_at INTEGER,
deleted_by TEXT(36),
deleted_at INTEGER,
CONSTRAINT Videos_PK PRIMARY KEY (id),
CONSTRAINT Videos_FK FOREIGN KEY (created_by) REFERENCES Persons(id),
CONSTRAINT Videos_FK_1 FOREIGN KEY (modified_by) REFERENCES Persons(id),
CONSTRAINT Videos_FK_2 FOREIGN KEY (deleted_by) REFERENCES Persons(id)
);
CREATE INDEX Videos_name_IDX ON Videos (name);
CREATE INDEX Videos_path_IDX ON Videos ("path");
CREATE INDEX Videos_url_IDX ON Videos (url);
CREATE INDEX Videos_alt_text_IDX ON Videos (alt_text);
CREATE INDEX Videos_is_public_IDX ON Videos (is_public);
CREATE INDEX Videos_allow_hotlinking_IDX ON Videos (allow_hotlinking);
CREATE INDEX Videos_created_by_IDX ON Videos (created_by);
CREATE INDEX Videos_deleted_at_IDX ON Videos (deleted_at);
```
# Articles
The Articles table will contain Articles!
``` sql
CREATE TABLE Articles (
id TEXT(36),
title TEXT,
body TEXT,
description TEXT,
created_by TEXT(36),
created_at INTEGER,
modified_at INTEGER,
published_at INTEGER,
deleted_at INTEGER,
is_public INTEGER DEFAULT (0),
is_draft INTEGER DEFAULT (1),
CONSTRAINT Articles_PK PRIMARY KEY (id),
CONSTRAINT Articles_FK FOREIGN KEY (created_by) REFERENCES Persons(id)
);
CREATE INDEX Articles_title_IDX ON Articles (title);
CREATE INDEX Articles_body_IDX ON Articles (body);
CREATE INDEX Articles_description_IDX ON Articles (description);
CREATE INDEX Articles_created_by_IDX ON Articles (created_by);
CREATE INDEX Articles_published_at_IDX ON Articles (published_at);
CREATE INDEX Articles_deleted_at_IDX ON Articles (deleted_at);
CREATE INDEX Articles_is_public_IDX ON Articles (is_public);
CREATE INDEX Articles_is_draft_IDX ON Articles (is_draft);
```
# ArticleTags
The ArticleTags table will contain Tags that have been assigned to an Article.
``` sql
CREATE TABLE ArticleTags (
article_id TEXT(36),
tag_id TEXT(36),
is_approved INTEGER DEFAULT (0),
CONSTRAINT ArticleTags_PK PRIMARY KEY (article_id,tag_id),
CONSTRAINT ArticleTags_FK FOREIGN KEY (article_id) REFERENCES Articles(id) ON DELETE CASCADE,
CONSTRAINT ArticleTags_FK_1 FOREIGN KEY (tag_id) REFERENCES Tags(id) ON DELETE CASCADE
);
CREATE INDEX ArticleTags_is_approved_IDX ON ArticleTags (is_approved);
```
# ArticleComments
The ArticleComments table will relate Comments to the Article they are about, if pertinent.
``` sql
CREATE TABLE ArticleComments (
article_id TEXT(36),
comment_id TEXT(36),
CONSTRAINT ArticleComments_PK PRIMARY KEY (article_id,comment_id),
CONSTRAINT ArticleComments_FK FOREIGN KEY (article_id) REFERENCES Articles(id) ON DELETE CASCADE,
CONSTRAINT ArticleComments_FK_1 FOREIGN KEY (comment_id) REFERENCES Comments(id) ON DELETE CASCADE
);
CREATE INDEX ArticleComments_article_id_IDX ON ArticleComments (article_id);
CREATE INDEX ArticleComments_comment_id_IDX ON ArticleComments (comment_id);
```
# LabelImages
# ArtistImages
# TrackImages
# AlbumImages
# PlaylistImages
# LabelVideos
# ArtistImages
# ArtistVideos
# TrackVideos
# AlbumImages
# AlbumVideos
# ArtistContacts
# TrackImages
# Articles
# TrackVideos
# ArticleTags
# PlaylistImages
# PlaylistVideos
# ArticleImages
# ArticleVideos
# ArticleComments