-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
services/headless-lms/migrations/20240823123921_add_code_giveaways.down.sql
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,2 @@ | ||
DROP TABLE code_giveaway_codes; | ||
DROP TABLE code_giveaways; |
35 changes: 35 additions & 0 deletions
35
services/headless-lms/migrations/20240823123921_add_code_giveaways.up.sql
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,35 @@ | ||
CREATE TABLE code_giveaways ( | ||
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY, | ||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
deleted_at TIMESTAMP WITH TIME ZONE, | ||
course_id UUID NOT NULL REFERENCES courses(id), | ||
); | ||
CREATE TRIGGER set_timestamp BEFORE | ||
UPDATE ON code_giveaways FOR EACH ROW EXECUTE PROCEDURE trigger_set_timestamp(); | ||
COMMENT ON TABLE code_giveaways IS 'With a code giveaway you can create a list of codes that can be distributed to students that complete a course module. To use the giveaway, the teacher needs to add a block to the course materil for the giveaway.'; | ||
COMMENT ON COLUMN code_giveaways.id IS 'A unique, stable identifier for the record.'; | ||
COMMENT ON COLUMN code_giveaways.created_at IS 'Timestamp when the record was created.'; | ||
COMMENT ON COLUMN code_giveaways.updated_at IS 'Timestamp when the record was last updated. The field is updated automatically by the set_timestamp trigger.'; | ||
COMMENT ON COLUMN code_giveaways.deleted_at IS 'Timestamp when the record was deleted. If null, the record is not deleted.'; | ||
COMMENT ON COLUMN code_giveaways.course_id IS 'The course the code giveaway is available on.'; | ||
|
||
CREATE TABLE code_giveaway_codes ( | ||
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY, | ||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
deleted_at TIMESTAMP WITH TIME ZONE, | ||
code_giveaway_id UUID NOT NULL REFERENCES code_giveaways(id), | ||
code_given_to_user_id UUID REFERENCES users(id), | ||
added_by_user_id UUID NOT NULL REFERENCES users(id), | ||
); | ||
CREATE TRIGGER set_timestamp BEFORE | ||
UPDATE ON code_giveaway_codes FOR EACH ROW EXECUTE PROCEDURE trigger_set_timestamp(); | ||
COMMENT ON TABLE code_giveaway_codes IS 'A code that is available in a code giveaway.'; | ||
COMMENT ON COLUMN code_giveaway_codes.id IS 'A unique, stable identifier for the record.'; | ||
COMMENT ON COLUMN code_giveaway_codes.created_at IS 'Timestamp when the record was created.'; | ||
COMMENT ON COLUMN code_giveaway_codes.updated_at IS 'Timestamp when the record was last updated. The field is updated automatically by the set_timestamp trigger.'; | ||
COMMENT ON COLUMN code_giveaway_codes.deleted_at IS 'Timestamp when the record was deleted. If null, the record is not deleted.'; | ||
COMMENT ON COLUMN code_giveaway_codes.code_giveaway_id IS 'The code giveaway the code is available in.'; | ||
COMMENT ON COLUMN code_giveaway_codes.code_given_to_user_id IS 'The user the code was given to. If null, the code has not been given to a user.'; | ||
COMMENT ON COLUMN code_giveaway_codes.added_by_user_id IS 'The user that added the code to the giveaway.'; |