From aa29ad20141c142f49cc733cc105b1fef7f96004 Mon Sep 17 00:00:00 2001 From: Haidang666 Date: Fri, 25 Jun 2021 10:44:08 +0700 Subject: [PATCH] Add database table schema, Fix indent --- DatabaseSchema.md | 183 +++++++++++++++++++++++++ databases/_sponsorTimes.db.sql | 6 +- databases/_upgrade_sponsorTimes_1.sql | 2 +- databases/_upgrade_sponsorTimes_10.sql | 12 +- databases/_upgrade_sponsorTimes_12.sql | 14 +- databases/_upgrade_sponsorTimes_6.sql | 6 +- databases/_upgrade_sponsorTimes_7.sql | 8 +- databases/_upgrade_sponsorTimes_8.sql | 10 +- databases/_upgrade_sponsorTimes_9.sql | 10 +- 9 files changed, 218 insertions(+), 33 deletions(-) create mode 100644 DatabaseSchema.md diff --git a/DatabaseSchema.md b/DatabaseSchema.md new file mode 100644 index 0000000..32fdc6e --- /dev/null +++ b/DatabaseSchema.md @@ -0,0 +1,183 @@ +# SponsorTimesDB + +[vipUsers](###vipUsers) +[sponsorTimes](###sponsorTimes) +[userNames](###userNames) +[categoryVotes](###categoryVotes) +[lockCategories](###lockCategories) +[warnings](###warnings) +[shadowBannedUsers](###shadowBannedUsers) +[unlistedVideos](###unlistedVideos) +[config](###config) + +### vipUsers +| Name | Type | | +| -- | :--: | -- | +| userID | TEXT | not null | + +| index | field | +| -- | :--: | +| vipUsers_index | userID | + +### sponsorTimes + +| Name | Type | | +| -- | :--: | -- | +| videoID | TEXT | not null | +| startTime | REAL | not null | +| endTime | REAL | not null | +| votes | INTEGER | not null | +| locked | INTEGER | not nul, default '0' | +| incorrectVotes | INTEGER | not null, default 1 | +| UUID | TEXT | not null, unique | +| userID | TEXT | not null | +| timeSubmitted | INTEGER | not null | +| views | INTEGER | not null | +| category | TEXT | not null, default 'sponsor' | +| service | TEXT | not nul, default 'Youtube' | +| videoDuration | INTEGER | not nul, default '0' | +| hidden | INTEGER | not nul, default '0' | +| reputation | REAL | not nul, default '0' | +| shadowHidden | INTEGER | not null | +| hashedVideoID | TEXT | not null, default '', sha256 | + +| index | field | +| -- | :--: | +| sponsorTime_timeSubmitted | timeSubmitted | +| sponsorTime_userID | userID | +| sponsorTimes_UUID | UUID | +| sponsorTimes_hashedVideoID_gin| hashedVideoID, category | +| sponsorTimes_videoID | videoID, service, category, timeSubmitted | + +### userNames + +| Name | Type | | +| -- | :--: | -- | +| userID | TEXT | not null | +| userName | TEXT | not null | +| locked | INTEGER | not nul, default '0' | + +| index | field | +| -- | :--: | +| userNames_userID | userID | + +### categoryVotes + +| Name | Type | | +| -- | :--: | -- | +| UUID | TEXT | not null | +| category | TEXT | not null | +| votes | INTEGER | not null, default 0 | + +| index | field | +| -- | :--: | +| categoryVotes_UUID_public | UUID, category | + +### lockCategories + +| Name | Type | | +| -- | :--: | -- | +| videoID | TEXT | not null | +| userID | TEXT | not null | +| category | TEXT | not null | + +| index | field | +| -- | :--: | +| noSegments_videoID | videoID | + +### warnings + +| Name | Type | | +| -- | :--: | -- | +| userID | TEXT | not null | +| issueTime | INTEGER | not null | +| issuerUserID | TEXT | not null | +| enabled | INTEGER | not null | + +| index | field | +| -- | :--: | +| warnings_index | userID | +| warnings_issueTime | issueTime | + +### shadowBannedUsers + +| Name | Type | | +| -- | :--: | -- | +| userID | TEXT | not null | + +| index | field | +| -- | :--: | +| shadowBannedUsers_index | userID | + +### unlistedVideos + +| Name | Type | | +| -- | :--: | -- | +| videoID | TEXT | not null | +| year | TEXT | not null | +| views | TEXT | not null | +| channelID | TEXT | not null | +| timeSubmitted | INTEGER | not null | + +### config + +| Name | Type | | +| -- | :--: | -- | +| key | TEXT | not null, unique | +| value | TEXT | not null | + + + +# Private + +[vote](###vote) +[categoryVotes](###categoryVotes) +[sponsorTimes](###sponsorTimes) +[config](###config) + +### vote + +| Name | Type | | +| -- | :--: | -- | +| UUID | TEXT | not null | +| userID | TEXT | not null | +| hashedIP | TEXT | not null | +| type | INTEGER | not null | + +| index | field | +| -- | :--: | +| votes_userID | UUID | + +### categoryVotes + +| Name | Type | | +| -- | :--: | -- | +| UUID | TEXT | not null | +| userID | TEXT | not null | +| hashedIP | TEXT | not null | +| category | TEXT | not null | +| timeSubmitted | INTEGER | not null | + +| index | field | +| -- | :--: | +| categoryVotes_UUID | UUID, userID, hasedIP, category | + +### sponsorTimes + +| Name | Type | | +| -- | :--: | -- | +| videoID | TEXT | not null | +| hashedIP | TEXT | not null | +| timeSubmitted | INTEGER | not null | + +| index | field | +| -- | :--: | +| sponsorTimes_hashedIP | hashedIP | +| privateDB_sponsorTimes_videoID | videoID | + +### config + +| Name | Type | | +| -- | :--: | -- | +| key | TEXT | not null | +| value | TEXT | not null | \ No newline at end of file diff --git a/databases/_sponsorTimes.db.sql b/databases/_sponsorTimes.db.sql index b52d888..38ed203 100644 --- a/databases/_sponsorTimes.db.sql +++ b/databases/_sponsorTimes.db.sql @@ -17,13 +17,15 @@ CREATE TABLE IF NOT EXISTS "sponsorTimes" ( "userID" TEXT NOT NULL, "timeSubmitted" INTEGER NOT NULL, "views" INTEGER NOT NULL, - "category" TEXT NOT NULL, + "category" TEXT NOT NULL, "shadowHidden" INTEGER NOT NULL ); + CREATE TABLE IF NOT EXISTS "userNames" ( "userID" TEXT NOT NULL, "userName" TEXT NOT NULL ); + CREATE TABLE IF NOT EXISTS "categoryVotes" ( "UUID" TEXT NOT NULL, "category" TEXT NOT NULL, @@ -31,7 +33,7 @@ CREATE TABLE IF NOT EXISTS "categoryVotes" ( ); CREATE TABLE IF NOT EXISTS "config" ( - "key" TEXT NOT NULL UNIQUE, + "key" TEXT NOT NULL UNIQUE, "value" TEXT NOT NULL ); diff --git a/databases/_upgrade_sponsorTimes_1.sql b/databases/_upgrade_sponsorTimes_1.sql index e394605..40d75e9 100644 --- a/databases/_upgrade_sponsorTimes_1.sql +++ b/databases/_upgrade_sponsorTimes_1.sql @@ -6,7 +6,7 @@ CREATE TABLE "sqlb_temp_table_1" ( "startTime" REAL NOT NULL, "endTime" REAL NOT NULL, "votes" INTEGER NOT NULL, - "incorrectVotes" INTEGER NOT NULL default 1, + "incorrectVotes" INTEGER NOT NULL default 1, "UUID" TEXT NOT NULL UNIQUE, "userID" TEXT NOT NULL, "timeSubmitted" INTEGER NOT NULL, diff --git a/databases/_upgrade_sponsorTimes_10.sql b/databases/_upgrade_sponsorTimes_10.sql index 174ceaf..e710594 100644 --- a/databases/_upgrade_sponsorTimes_10.sql +++ b/databases/_upgrade_sponsorTimes_10.sql @@ -6,18 +6,18 @@ CREATE TABLE "sqlb_temp_table_10" ( "startTime" REAL NOT NULL, "endTime" REAL NOT NULL, "votes" INTEGER NOT NULL, - "locked" INTEGER NOT NULL default '0', - "incorrectVotes" INTEGER NOT NULL default '1', + "locked" INTEGER NOT NULL default '0', + "incorrectVotes" INTEGER NOT NULL default '1', "UUID" TEXT NOT NULL UNIQUE, "userID" TEXT NOT NULL, "timeSubmitted" INTEGER NOT NULL, "views" INTEGER NOT NULL, "category" TEXT NOT NULL DEFAULT 'sponsor', - "service" TEXT NOT NULL DEFAULT 'YouTube', - "videoDuration" REAL NOT NULL DEFAULT '0', - "hidden" INTEGER NOT NULL DEFAULT '0', + "service" TEXT NOT NULL DEFAULT 'YouTube', + "videoDuration" REAL NOT NULL DEFAULT '0', + "hidden" INTEGER NOT NULL DEFAULT '0', "shadowHidden" INTEGER NOT NULL, - "hashedVideoID" TEXT NOT NULL default '' + "hashedVideoID" TEXT NOT NULL default '' ); INSERT INTO sqlb_temp_table_10 SELECT "videoID","startTime","endTime","votes","locked","incorrectVotes","UUID","userID","timeSubmitted","views","category","service","videoDuration",0,"shadowHidden","hashedVideoID" FROM "sponsorTimes"; diff --git a/databases/_upgrade_sponsorTimes_12.sql b/databases/_upgrade_sponsorTimes_12.sql index ef4b2d0..0ad6f66 100644 --- a/databases/_upgrade_sponsorTimes_12.sql +++ b/databases/_upgrade_sponsorTimes_12.sql @@ -6,19 +6,19 @@ CREATE TABLE "sqlb_temp_table_12" ( "startTime" REAL NOT NULL, "endTime" REAL NOT NULL, "votes" INTEGER NOT NULL, - "locked" INTEGER NOT NULL default '0', - "incorrectVotes" INTEGER NOT NULL default '1', + "locked" INTEGER NOT NULL default '0', + "incorrectVotes" INTEGER NOT NULL default '1', "UUID" TEXT NOT NULL UNIQUE, "userID" TEXT NOT NULL, "timeSubmitted" INTEGER NOT NULL, "views" INTEGER NOT NULL, "category" TEXT NOT NULL DEFAULT 'sponsor', - "service" TEXT NOT NULL DEFAULT 'YouTube', - "videoDuration" REAL NOT NULL DEFAULT '0', - "hidden" INTEGER NOT NULL DEFAULT '0', - "reputation" REAL NOT NULL DEFAULT 0, + "service" TEXT NOT NULL DEFAULT 'YouTube', + "videoDuration" REAL NOT NULL DEFAULT '0', + "hidden" INTEGER NOT NULL DEFAULT '0', + "reputation" REAL NOT NULL DEFAULT 0, "shadowHidden" INTEGER NOT NULL, - "hashedVideoID" TEXT NOT NULL default '' + "hashedVideoID" TEXT NOT NULL default '' ); INSERT INTO sqlb_temp_table_12 SELECT "videoID","startTime","endTime","votes","locked","incorrectVotes","UUID","userID","timeSubmitted","views","category","service","videoDuration","hidden",0,"shadowHidden","hashedVideoID" FROM "sponsorTimes"; diff --git a/databases/_upgrade_sponsorTimes_6.sql b/databases/_upgrade_sponsorTimes_6.sql index 14bd646..adef175 100644 --- a/databases/_upgrade_sponsorTimes_6.sql +++ b/databases/_upgrade_sponsorTimes_6.sql @@ -6,15 +6,15 @@ CREATE TABLE "sqlb_temp_table_6" ( "startTime" REAL NOT NULL, "endTime" REAL NOT NULL, "votes" INTEGER NOT NULL, - "locked" INTEGER NOT NULL default '0', - "incorrectVotes" INTEGER NOT NULL default '1', + "locked" INTEGER NOT NULL default '0', + "incorrectVotes" INTEGER NOT NULL default '1', "UUID" TEXT NOT NULL UNIQUE, "userID" TEXT NOT NULL, "timeSubmitted" INTEGER NOT NULL, "views" INTEGER NOT NULL, "category" TEXT NOT NULL DEFAULT 'sponsor', "shadowHidden" INTEGER NOT NULL, - "hashedVideoID" TEXT NOT NULL default '' + "hashedVideoID" TEXT NOT NULL default '' ); INSERT INTO sqlb_temp_table_6 SELECT "videoID","startTime","endTime","votes",'0',"incorrectVotes","UUID","userID","timeSubmitted","views","category","shadowHidden","hashedVideoID" FROM "sponsorTimes"; diff --git a/databases/_upgrade_sponsorTimes_7.sql b/databases/_upgrade_sponsorTimes_7.sql index 8f6060b..532b957 100644 --- a/databases/_upgrade_sponsorTimes_7.sql +++ b/databases/_upgrade_sponsorTimes_7.sql @@ -6,16 +6,16 @@ CREATE TABLE "sqlb_temp_table_7" ( "startTime" REAL NOT NULL, "endTime" REAL NOT NULL, "votes" INTEGER NOT NULL, - "locked" INTEGER NOT NULL default '0', - "incorrectVotes" INTEGER NOT NULL default '1', + "locked" INTEGER NOT NULL default '0', + "incorrectVotes" INTEGER NOT NULL default '1', "UUID" TEXT NOT NULL UNIQUE, "userID" TEXT NOT NULL, "timeSubmitted" INTEGER NOT NULL, "views" INTEGER NOT NULL, "category" TEXT NOT NULL DEFAULT 'sponsor', - "service" TEXT NOT NULL DEFAULT 'YouTube', + "service" TEXT NOT NULL DEFAULT 'YouTube', "shadowHidden" INTEGER NOT NULL, - "hashedVideoID" TEXT NOT NULL default '' + "hashedVideoID" TEXT NOT NULL default '' ); INSERT INTO sqlb_temp_table_7 SELECT "videoID","startTime","endTime","votes","locked","incorrectVotes","UUID","userID","timeSubmitted","views","category",'YouTube', "shadowHidden","hashedVideoID" FROM "sponsorTimes"; diff --git a/databases/_upgrade_sponsorTimes_8.sql b/databases/_upgrade_sponsorTimes_8.sql index ccc2ec9..d6c76d3 100644 --- a/databases/_upgrade_sponsorTimes_8.sql +++ b/databases/_upgrade_sponsorTimes_8.sql @@ -6,17 +6,17 @@ CREATE TABLE "sqlb_temp_table_8" ( "startTime" REAL NOT NULL, "endTime" REAL NOT NULL, "votes" INTEGER NOT NULL, - "locked" INTEGER NOT NULL default '0', - "incorrectVotes" INTEGER NOT NULL default '1', + "locked" INTEGER NOT NULL default '0', + "incorrectVotes" INTEGER NOT NULL default '1', "UUID" TEXT NOT NULL UNIQUE, "userID" TEXT NOT NULL, "timeSubmitted" INTEGER NOT NULL, "views" INTEGER NOT NULL, "category" TEXT NOT NULL DEFAULT 'sponsor', - "service" TEXT NOT NULL DEFAULT 'YouTube', - "videoDuration" INTEGER NOT NULL DEFAULT '0', + "service" TEXT NOT NULL DEFAULT 'YouTube', + "videoDuration" INTEGER NOT NULL DEFAULT '0', "shadowHidden" INTEGER NOT NULL, - "hashedVideoID" TEXT NOT NULL default '' + "hashedVideoID" TEXT NOT NULL default '' ); INSERT INTO sqlb_temp_table_8 SELECT "videoID","startTime","endTime","votes","locked","incorrectVotes","UUID","userID","timeSubmitted","views","category","service",'0', "shadowHidden","hashedVideoID" FROM "sponsorTimes"; diff --git a/databases/_upgrade_sponsorTimes_9.sql b/databases/_upgrade_sponsorTimes_9.sql index 5015a4a..c8d453b 100644 --- a/databases/_upgrade_sponsorTimes_9.sql +++ b/databases/_upgrade_sponsorTimes_9.sql @@ -6,17 +6,17 @@ CREATE TABLE "sqlb_temp_table_9" ( "startTime" REAL NOT NULL, "endTime" REAL NOT NULL, "votes" INTEGER NOT NULL, - "locked" INTEGER NOT NULL default '0', - "incorrectVotes" INTEGER NOT NULL default '1', + "locked" INTEGER NOT NULL default '0', + "incorrectVotes" INTEGER NOT NULL default '1', "UUID" TEXT NOT NULL UNIQUE, "userID" TEXT NOT NULL, "timeSubmitted" INTEGER NOT NULL, "views" INTEGER NOT NULL, "category" TEXT NOT NULL DEFAULT 'sponsor', - "service" TEXT NOT NULL DEFAULT 'YouTube', - "videoDuration" REAL NOT NULL DEFAULT '0', + "service" TEXT NOT NULL DEFAULT 'YouTube', + "videoDuration" REAL NOT NULL DEFAULT '0', "shadowHidden" INTEGER NOT NULL, - "hashedVideoID" TEXT NOT NULL default '' + "hashedVideoID" TEXT NOT NULL default '' ); INSERT INTO sqlb_temp_table_9 SELECT "videoID","startTime","endTime","votes","locked","incorrectVotes","UUID","userID","timeSubmitted","views","category","service",'0', "shadowHidden","hashedVideoID" FROM "sponsorTimes";