-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save streams representation to the database (#59)
* Add stream DB module + migration * Add processing to other routes for twitch callback * Fix rollback * Add user FK to stream * Move ChatMessagePayload to new vendors module * Move NATS to its own module * Move events to their own module * Move queue to its own module * Delete workers module * Add event stream support for stream.online|offline * Add support for creating stream in db on stream.online event * Check for stream online event when saving new stream
- Loading branch information
1 parent
706d32b
commit ac3ebd9
Showing
25 changed files
with
400 additions
and
72 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,3 @@ | ||
DROP TRIGGER IF EXISTS update_streams_updated_at ON streams; | ||
|
||
DROP TABLE IF EXISTS streams; |
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,27 @@ | ||
CREATE TABLE IF NOT EXISTS streams ( | ||
id UUID PRIMARY KEY DEFAULT gen_random_uuid (), | ||
user_id UUID NOT NULL REFERENCES users (id) ON DELETE CASCADE, | ||
start_time TIMESTAMP | ||
WITH | ||
TIME ZONE NOT NULL, | ||
end_time TIMESTAMP | ||
WITH | ||
TIME ZONE, | ||
event_log_url TEXT, | ||
video_url TEXT, | ||
created_at TIMESTAMP | ||
WITH | ||
TIME ZONE NOT NULL DEFAULT NOW (), | ||
updated_at TIMESTAMP | ||
WITH | ||
TIME ZONE NOT NULL DEFAULT NOW () | ||
); | ||
|
||
-- Add an index on start_time for efficient querying | ||
CREATE INDEX idx_streams_start_time ON streams (start_time); | ||
|
||
CREATE INDEX idx_streams_user_id ON streams (user_id); | ||
|
||
-- Create trigger using existing function | ||
CREATE TRIGGER update_streams_updated_at BEFORE | ||
UPDATE ON streams FOR EACH ROW EXECUTE FUNCTION update_updated_at_column (); |
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
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
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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod accounts; | ||
pub mod streams; | ||
pub mod users; | ||
pub mod videos; | ||
|
||
|
Oops, something went wrong.