From 4ad553478baad093d1e7f545688dd97a8438ed32 Mon Sep 17 00:00:00 2001 From: Tristan Date: Fri, 21 Jun 2024 00:50:10 +0200 Subject: [PATCH 1/8] chore: fix misleading/unclear migration comments --- databases/_upgrade_sponsorTimes_6.sql | 2 +- databases/_upgrade_sponsorTimes_8.sql | 2 +- databases/_upgrade_sponsorTimes_9.sql | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/databases/_upgrade_sponsorTimes_6.sql b/databases/_upgrade_sponsorTimes_6.sql index adef175..e758769 100644 --- a/databases/_upgrade_sponsorTimes_6.sql +++ b/databases/_upgrade_sponsorTimes_6.sql @@ -1,6 +1,6 @@ BEGIN TRANSACTION; -/* Add new voting field */ +/* Add 'locked' field */ CREATE TABLE "sqlb_temp_table_6" ( "videoID" TEXT NOT NULL, "startTime" REAL NOT NULL, diff --git a/databases/_upgrade_sponsorTimes_8.sql b/databases/_upgrade_sponsorTimes_8.sql index d6c76d3..6f79ac4 100644 --- a/databases/_upgrade_sponsorTimes_8.sql +++ b/databases/_upgrade_sponsorTimes_8.sql @@ -1,6 +1,6 @@ BEGIN TRANSACTION; -/* Add Service field */ +/* Add 'videoDuration' field */ CREATE TABLE "sqlb_temp_table_8" ( "videoID" TEXT NOT NULL, "startTime" REAL NOT NULL, diff --git a/databases/_upgrade_sponsorTimes_9.sql b/databases/_upgrade_sponsorTimes_9.sql index c8d453b..922c301 100644 --- a/databases/_upgrade_sponsorTimes_9.sql +++ b/databases/_upgrade_sponsorTimes_9.sql @@ -1,6 +1,6 @@ BEGIN TRANSACTION; -/* Add Service field */ +/* Change 'videoDuration' field from INTEGER to REAL */ CREATE TABLE "sqlb_temp_table_9" ( "videoID" TEXT NOT NULL, "startTime" REAL NOT NULL, From 44221042942412e39c496cea9dcf7c693e8b3e2b Mon Sep 17 00:00:00 2001 From: Tristan Date: Fri, 21 Jun 2024 01:34:15 +0200 Subject: [PATCH 2/8] docs: format lists --- DatabaseSchema.md | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/DatabaseSchema.md b/DatabaseSchema.md index 535e667..9083d1a 100644 --- a/DatabaseSchema.md +++ b/DatabaseSchema.md @@ -1,15 +1,17 @@ # SponsorTimesDB -[vipUsers](#vipUsers) -[sponsorTimes](#sponsorTimes) -[userNames](#userNames) -[categoryVotes](#categoryVotes) -[lockCategories](#lockCategories) -[warnings](#warnings) -[shadowBannedUsers](#shadowBannedUsers) -[unlistedVideos](#unlistedVideos) -[config](#config) -[archivedSponsorTimes](#archivedSponsorTimes) +- [vipUsers](#vipusers) +- [sponsorTimes](#sponsortimes) +- [userNames](#usernames) +- [categoryVotes](#categoryvotes) +- [lockCategories](#lockcategories) +- [warnings](#warnings) +- [shadowBannedUsers](#shadowbannedusers) +- [videoInfo](#videoinfo) +- [unlistedVideos](#unlistedvideos) +- [config](#config) +- [archivedSponsorTimes](#archivedsponsortimes) +- [ratings](#ratings) ### vipUsers | Name | Type | | @@ -192,13 +194,13 @@ # Private -[votes](#votes) -[categoryVotes](#categoryVotes) -[sponsorTimes](#sponsorTimes) -[config](#config) -[ratings](#ratings) -[tempVipLog](#tempVipLog) -[userNameLogs](#userNameLogs) +- [votes](#votes) +- [categoryVotes](#categoryVotes) +- [sponsorTimes](#sponsorTimes) +- [config](#config) +- [ratings](#ratings) +- [tempVipLog](#tempVipLog) +- [userNameLogs](#userNameLogs) ### votes @@ -280,4 +282,4 @@ | newUserName | TEXT | not null | | oldUserName | TEXT | not null | | updatedByAdmin | BOOLEAN | not null | -| updatedAt | INTEGER | not null | +| updatedAt | INTEGER | not null | \ No newline at end of file From 96dd9eceb307b16a34d66137ffad86faaa5fd476 Mon Sep 17 00:00:00 2001 From: Tristan Date: Fri, 21 Jun 2024 01:34:25 +0200 Subject: [PATCH 3/8] docs: update public indexes --- DatabaseSchema.md | 52 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/DatabaseSchema.md b/DatabaseSchema.md index 9083d1a..d6fa84d 100644 --- a/DatabaseSchema.md +++ b/DatabaseSchema.md @@ -1,4 +1,4 @@ -# SponsorTimesDB +# Public - [vipUsers](#vipusers) - [sponsorTimes](#sponsortimes) @@ -12,6 +12,11 @@ - [config](#config) - [archivedSponsorTimes](#archivedsponsortimes) - [ratings](#ratings) +- [userFeatures](#userFeatures) +- [titles](#titles) +- [titleVotes](#titleVotes) +- [thumbnails](#thumbnails) +- [thumbnailVotes](#thumbnailVotes) ### vipUsers | Name | Type | | @@ -52,8 +57,10 @@ | sponsorTime_timeSubmitted | timeSubmitted | | sponsorTime_userID | userID | | sponsorTimes_UUID | UUID | -| sponsorTimes_hashedVideoID | hashedVideoID, category | -| sponsorTimes_videoID | videoID, service, category, timeSubmitted | +| sponsorTimes_hashedVideoID | service, hashedVideoID, startTime | +| sponsorTimes_videoID | service, videoID, startTime | +| sponsorTimes_videoID_category | videoID, category | +| sponsorTimes_description_gin | description, category | ### userNames @@ -107,7 +114,7 @@ | index | field | | -- | :--: | -| warnings_index | userID | +| warnings_index | userID, issueTime, enabled | | warnings_issueTime | issueTime | ### shadowBannedUsers @@ -131,8 +138,8 @@ | index | field | | -- | :--: | -| videoInfo_videoID | timeSubmitted | -| videoInfo_channelID | userID | +| videoInfo_videoID | videoID | +| videoInfo_channelID | channelID | ### unlistedVideos @@ -192,6 +199,39 @@ | ratings_hashedVideoID | hashedVideoID, service | | ratings_videoID | videoID, service | +### userFeatures + +| index | field | +| -- | :--: | +| userFeatures_userID | userID, feature | + +### titles + +| index | field | +| -- | :--: | +| titles_timeSubmitted | timeSubmitted | +| titles_userID_timeSubmitted | videoID, service, userID, timeSubmitted | +| titles_videoID | videoID, service | +| titles_hashedVideoID_2 | service, hashedVideoID, timeSubmitted | + +### titleVotes +| index | field | +| -- | :--: | +| titleVotes_votes | UUID, votes + +### thumbnails +| index | field | +| -- | :--: | +| thumbnails_timeSubmitted | timeSubmitted | +| thumbnails_votes_timeSubmitted | videoID, service, userID, timeSubmitted | +| thumbnails_videoID | videoID, service | +| thumbnails_hashedVideoID_2 | service, hashedVideoID, timeSubmitted | + +### thumbnailVotes +| index | field | +| -- | :--: | +| thumbnailVotes_votes | UUID, votes + # Private - [votes](#votes) From d08cfee5b471c5a64da97a5a42ca098e0e744394 Mon Sep 17 00:00:00 2001 From: Tristan Date: Fri, 21 Jun 2024 01:35:38 +0200 Subject: [PATCH 4/8] docs: update private indexes --- DatabaseSchema.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/DatabaseSchema.md b/DatabaseSchema.md index d6fa84d..28c0952 100644 --- a/DatabaseSchema.md +++ b/DatabaseSchema.md @@ -268,7 +268,7 @@ | index | field | | -- | :--: | -| categoryVotes_UUID | UUID, userID, hasedIP, category | +| categoryVotes_UUID | UUID, userID, hashedIP, category | ### sponsorTimes @@ -281,8 +281,7 @@ | index | field | | -- | :--: | -| sponsorTimes_hashedIP | hashedIP | -| privateDB_sponsorTimes_videoID_v2 | videoID, service | +| privateDB_sponsorTimes_v4 | videoID, service, timeSubmitted | ### config From 96feaf3cbeddba54f87b03bc64f7fe3f929c71fe Mon Sep 17 00:00:00 2001 From: Tristan Date: Fri, 21 Jun 2024 03:08:38 +0200 Subject: [PATCH 5/8] docs: update public schemas --- DatabaseSchema.md | 100 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 94 insertions(+), 6 deletions(-) diff --git a/DatabaseSchema.md b/DatabaseSchema.md index 28c0952..4b5f872 100644 --- a/DatabaseSchema.md +++ b/DatabaseSchema.md @@ -13,15 +13,17 @@ - [archivedSponsorTimes](#archivedsponsortimes) - [ratings](#ratings) - [userFeatures](#userFeatures) +- [shadowBannedIPs](#shadowBannedIPs) - [titles](#titles) - [titleVotes](#titleVotes) - [thumbnails](#thumbnails) +- [thumbnailTimestamps](#thumbnailTimestamps) - [thumbnailVotes](#thumbnailVotes) ### vipUsers | Name | Type | | | -- | :--: | -- | -| userID | TEXT | not null | +| userID | TEXT | not null, primary key | | index | field | | -- | :--: | @@ -37,7 +39,7 @@ | votes | INTEGER | not null | | locked | INTEGER | not null, default '0' | | incorrectVotes | INTEGER | not null, default 1 | -| UUID | TEXT | not null, unique | +| UUID | TEXT | not null, unique, primary key | | userID | TEXT | not null | | timeSubmitted | INTEGER | not null | | views | INTEGER | not null | @@ -66,7 +68,7 @@ | Name | Type | | | -- | :--: | -- | -| userID | TEXT | not null | +| userID | TEXT | not null, primary key | | userName | TEXT | not null | | locked | INTEGER | not nul, default '0' | @@ -81,6 +83,7 @@ | UUID | TEXT | not null | | category | TEXT | not null | | votes | INTEGER | not null, default 0 | +| id | SERIAL | primary key | index | field | | -- | :--: | @@ -97,6 +100,7 @@ | hashedVideoID | TEXT | not null, default '' | | reason | TEXT | not null, default '' | | service | TEXT | not null, default 'YouTube' | +| id | SERIAL | primary key | index | field | | -- | :--: | @@ -111,6 +115,11 @@ | issuerUserID | TEXT | not null | | enabled | INTEGER | not null | | reason | TEXT | not null, default '' | +| type | INTEGER | default 0 | + +| constraint | field | +| -- | :--: | +| PRIMARY KEY | userID, issueTime | | index | field | | -- | :--: | @@ -121,7 +130,7 @@ | Name | Type | | | -- | :--: | -- | -| userID | TEXT | not null | +| userID | TEXT | not null, primary key | | index | field | | -- | :--: | @@ -151,12 +160,13 @@ | channelID | TEXT | not null | | timeSubmitted | INTEGER | not null | | service | TEXT | not null, default 'YouTube' | +| id | SERIAL | primary key ### config | Name | Type | | | -- | :--: | -- | -| key | TEXT | not null, unique | +| key | TEXT | not null, unique, primary key | | value | TEXT | not null | ### archivedSponsorTimes @@ -169,7 +179,7 @@ | votes | INTEGER | not null | | locked | INTEGER | not null, default '0' | | incorrectVotes | INTEGER | not null, default 1 | -| UUID | TEXT | not null, unique | +| UUID | TEXT | not null, unique, primary key | | userID | TEXT | not null | | timeSubmitted | INTEGER | not null | | views | INTEGER | not null | @@ -182,6 +192,7 @@ | shadowHidden | INTEGER | not null | | hashedVideoID | TEXT | not null, default '', sha256 | | userAgent | TEXT | not null, default '' | +| description | TEXT | not null, default '' | ### ratings @@ -192,6 +203,7 @@ | type | INTEGER | not null | | count | INTEGER | not null | | hashedVideoID | TEXT | not null | +| id | SERIAL | primary key | index | field | | -- | :--: | @@ -200,13 +212,38 @@ | ratings_videoID | videoID, service | ### userFeatures +| userID | TEXT | not null | +| feature | INTEGER | not null | +| issuerUserID | TEXT | not null | +| timeSubmitted | INTEGER | not null | + +| constraint | field | +| -- | :--: | +| primary key | userID, feature | | index | field | | -- | :--: | | userFeatures_userID | userID, feature | +### shadowBannedIPs + +| Name | Type | | +| -- | :--: | -- | +| hashedIP | TEXT | not null, primary key | + ### titles +| Name | Type | | +| -- | :--: | -- | +| videoID | TEXT | not null | +| title | TEXT | not null | +| original | INTEGER | default 0 | +| userID | TEXT | not null +| service | TEXT not null | +| hashedVideoID | TEXT | not null | +| timeSubmitted | INTEGER | not null | +| UUID | TEXT | not null, primary key + | index | field | | -- | :--: | | titles_timeSubmitted | timeSubmitted | @@ -215,11 +252,37 @@ | titles_hashedVideoID_2 | service, hashedVideoID, timeSubmitted | ### titleVotes + +| Name | Type | | +| -- | :--: | -- | +| UUID | TEXT | not null, primary key | +| votes | INTEGER | not null, default 0 | +| locked | INTEGER | not null, default 0 | +| shadowHidden | INTEGER | not null, default 0 | +| verification | INTEGER | default 0 | +| downvotes | INTEGER | default 0 | +| removed | INTEGER | default 0 | + +| constraint | field | +| -- | :--: | +| foreign key | UUID references "titles"("UUID") + | index | field | | -- | :--: | | titleVotes_votes | UUID, votes ### thumbnails + +| Name | Type | | +| -- | :--: | -- | +| UUID | TEXT | not null | +| original | INTEGER | default 0 | +| userID | TEXT | not null | +| service | TEXT | not null | +| hashedVideoID | TEXT | not null | +| timeSubmitted | INTEGER | not null | +| UUID | TEXT | not null, primary key | + | index | field | | -- | :--: | | thumbnails_timeSubmitted | timeSubmitted | @@ -227,7 +290,32 @@ | thumbnails_videoID | videoID, service | | thumbnails_hashedVideoID_2 | service, hashedVideoID, timeSubmitted | +### thumbnailTimestamps + +| index | field | +| -- | :--: | +| UUID | TEXT | not null, primary key +| timestamp | INTEGER | not null, default 0 + +| constraint | field | +| -- | :--: | +| foreign key | UUID references "thumbnails"("UUID") + ### thumbnailVotes + +| index | field | +| -- | :--: | +| UUID | TEXT | not null, primary key | +| votes | INTEGER | not null, default 0 | +| locked | INTEGER |not null, default 0 | +| shadowHidden | INTEGER | not null, default 0 | +| downvotes | INTEGER | default 0 | +| removed | INTEGER | default 0 | + +| constraint | field | +| -- | :--: | +| foreign key | UUID references "thumbnails"("UUID") + | index | field | | -- | :--: | | thumbnailVotes_votes | UUID, votes From 8e5084cd72d54f486959baaf8431b706a5be7b15 Mon Sep 17 00:00:00 2001 From: Tristan Date: Fri, 21 Jun 2024 03:11:28 +0200 Subject: [PATCH 6/8] docs: update private schemas --- DatabaseSchema.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/DatabaseSchema.md b/DatabaseSchema.md index 4b5f872..6e3f4f7 100644 --- a/DatabaseSchema.md +++ b/DatabaseSchema.md @@ -339,6 +339,7 @@ | hashedIP | TEXT | not null | | type | INTEGER | not null | | originalVoteType | INTEGER | not null | # Since type was reused to also specify the number of votes removed when less than 0, this is being used for the actual type +| id | SERIAL | primary key | | index | field | | -- | :--: | @@ -353,6 +354,7 @@ | hashedIP | TEXT | not null | | category | TEXT | not null | | timeSubmitted | INTEGER | not null | +| id | SERIAL | primary key | | index | field | | -- | :--: | @@ -366,6 +368,7 @@ | hashedIP | TEXT | not null | | timeSubmitted | INTEGER | not null | | service | TEXT | not null, default 'YouTube' | +| id | SERIAL | primary key | | index | field | | -- | :--: | @@ -375,7 +378,7 @@ | Name | Type | | | -- | :--: | -- | -| key | TEXT | not null | +| key | TEXT | not null, primary key | | value | TEXT | not null | ### ratings @@ -388,6 +391,7 @@ | type | INTEGER | not null | | timeSubmitted | INTEGER | not null | | hashedIP | TEXT | not null | +| id | SERIAL | primary key | | index | field | | -- | :--: | @@ -400,6 +404,7 @@ | targetUserID | TEXT | not null | | enabled | BOOLEAN | not null | | updatedAt | INTEGER | not null | +| id | SERIAL | primary key | ### userNameLogs @@ -409,4 +414,5 @@ | newUserName | TEXT | not null | | oldUserName | TEXT | not null | | updatedByAdmin | BOOLEAN | not null | -| updatedAt | INTEGER | not null | \ No newline at end of file +| updatedAt | INTEGER | not null | +| id | SERIAL | primary key | \ No newline at end of file From 1a0b6ab097e175e4cbd50deeea0fdb78b66620cb Mon Sep 17 00:00:00 2001 From: Tristan Date: Fri, 21 Jun 2024 03:15:07 +0200 Subject: [PATCH 7/8] Update DatabaseSchema.md --- DatabaseSchema.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DatabaseSchema.md b/DatabaseSchema.md index 6e3f4f7..527325f 100644 --- a/DatabaseSchema.md +++ b/DatabaseSchema.md @@ -1,4 +1,4 @@ -# Public +# SponsorTimesDB - [vipUsers](#vipusers) - [sponsorTimes](#sponsortimes) From 3b03792903300b95a6c63d32b8d13226b8545d4d Mon Sep 17 00:00:00 2001 From: Tristan Date: Fri, 21 Jun 2024 03:17:31 +0200 Subject: [PATCH 8/8] docs: fix userFeatures md list --- DatabaseSchema.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DatabaseSchema.md b/DatabaseSchema.md index 527325f..1b69da4 100644 --- a/DatabaseSchema.md +++ b/DatabaseSchema.md @@ -212,6 +212,8 @@ | ratings_videoID | videoID, service | ### userFeatures +| Name | Type | | +| -- | :--: | -- | | userID | TEXT | not null | | feature | INTEGER | not null | | issuerUserID | TEXT | not null |