-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move sql to app for future docker image
- Loading branch information
Dima
committed
Jan 6, 2024
1 parent
ccecd4f
commit efa0a25
Showing
4 changed files
with
41 additions
and
38 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package api | ||
|
||
const CreateTablesIfNotExists = ` | ||
CREATE TABLE IF NOT EXISTS videos | ||
( | ||
id STRING PRIMARY KEY, | ||
uploaded INTEGER, | ||
title STRING, | ||
views INTEGER, | ||
vertical INTEGER, | ||
category INTEGER | ||
); | ||
CREATE TABLE IF NOT EXISTS visitors ( | ||
id STRING PRIMARY KEY, | ||
last_seen INTEGER | ||
); | ||
CREATE TABLE IF NOT EXISTS videos_visitors | ||
( | ||
visitor_id STRING, | ||
video_id STRING, | ||
PRIMARY KEY (visitor_id, video_id), | ||
FOREIGN KEY (video_id) REFERENCES videos (id) ON DELETE CASCADE, | ||
FOREIGN KEY (visitor_id) REFERENCES visitors (id) ON DELETE CASCADE | ||
); | ||
CREATE TABLE IF NOT EXISTS reactions | ||
( | ||
cool INTEGER, | ||
visitor_id STRING, | ||
video_id STRING, | ||
PRIMARY KEY (visitor_id, video_id), | ||
FOREIGN KEY (video_id) REFERENCES videos (id) ON DELETE CASCADE, | ||
FOREIGN KEY (visitor_id) REFERENCES visitors (id) ON DELETE CASCADE | ||
); | ||
` |
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