A code that is available in a code giveaway. A user can only receive one code from a giveaway.
Name | Type | Default | Nullable | Children | Parents | Comment |
---|---|---|---|---|---|---|
added_by_user_id | uuid | false | public.users | The user that added the code to the giveaway. | ||
code | varchar(2048) | false | The code that is given to a user. | |||
code_giveaway_id | uuid | false | public.code_giveaways | The code giveaway the code is available in. | ||
code_given_to_user_id | uuid | true | public.users | The user the code was given to. If null, the code has not been given to a user. | ||
created_at | timestamp with time zone | now() | false | Timestamp when the record was created. | ||
deleted_at | timestamp with time zone | true | Timestamp when the record was deleted. If null, the record is not deleted. | |||
id | uuid | uuid_generate_v4() | false | A unique, stable identifier for the record. | ||
updated_at | timestamp with time zone | now() | false | Timestamp when the record was last updated. The field is updated automatically by the set_timestamp trigger. |
Name | Type | Definition |
---|---|---|
code_giveaway_codes_added_by_user_id_fkey | FOREIGN KEY | FOREIGN KEY (added_by_user_id) REFERENCES users(id) |
code_giveaway_codes_code_giveaway_id_code_deleted_at_key | UNIQUE | UNIQUE NULLS NOT DISTINCT (code_giveaway_id, code, deleted_at) |
code_giveaway_codes_code_giveaway_id_fkey | FOREIGN KEY | FOREIGN KEY (code_giveaway_id) REFERENCES code_giveaways(id) |
code_giveaway_codes_code_given_to_user_id_fkey | FOREIGN KEY | FOREIGN KEY (code_given_to_user_id) REFERENCES users(id) |
code_giveaway_codes_pkey | PRIMARY KEY | PRIMARY KEY (id) |
Name | Definition |
---|---|
code_giveaway_codes_code_giveaway_id_code_deleted_at_key | CREATE UNIQUE INDEX code_giveaway_codes_code_giveaway_id_code_deleted_at_key ON public.code_giveaway_codes USING btree (code_giveaway_id, code, deleted_at) NULLS NOT DISTINCT |
code_giveaway_codes_pkey | CREATE UNIQUE INDEX code_giveaway_codes_pkey ON public.code_giveaway_codes USING btree (id) |
giveaway_codes_one_code_per_user | CREATE UNIQUE INDEX giveaway_codes_one_code_per_user ON public.code_giveaway_codes USING btree (code_giveaway_id, code_given_to_user_id) WHERE (deleted_at IS NULL) |
Name | Definition |
---|---|
set_timestamp | CREATE TRIGGER set_timestamp BEFORE UPDATE ON public.code_giveaway_codes FOR EACH ROW EXECUTE FUNCTION trigger_set_timestamp() |
Generated by tbls