CHAL-95 #done Add a customer_rewards schema#76
CHAL-95 #done Add a customer_rewards schema#76Ris345 wants to merge 27 commits into8by8-org:rewardsfrom
Conversation
This reverts commit 24505e9.
This reverts commit 5ce525d.
* Welcome file.md created from https://stackedit.io/ * How to set up your development environment.md created from https://stackedit.io/ * Common variables.md created from https://stackedit.io/ * Home.md created from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Home.md updated from https://stackedit.io/ * Added Main Page to wiki. * Added development environment setup * Delete CONTRIBUTING.md * Delete Common variables.md * Delete Home.md * Delete How to set up your development environment.md * Delete STYLE_GUIDE.md * Delete doc_base.txt * Delete Welcome file.md * Update Home.md made requested changes from PR 8by8-org#73 * Updated and renamed file added details specified in PR 8by8-org#73 * Update Getting Started.md * Added Links and other change specified Added a break to Line 6 and added a few links to the bottom of the page * Update Home.md Added table of contents * Update Home.md Rearranged table of contents, external links * Changed Getting Started.md file for updated version provided * Deleted old Getting Started file
dvorakjt
left a comment
There was a problem hiding this comment.
Hi Rishav,
Great work! Just a few minor changes to request. See the comments below for details.
Additionally, we can optimize this further by creating indices on foreign key fields for faster lookup (PostgreSQL doesn't do this automatically). We should also enable RLS and create security policies on these tables. Snapshots should be accessible by any authenticated user and claimed rewards should only be accessible by the referenced user.
Great work so far!
| create table claimed_rewards ( | ||
| id serial primary key, | ||
| user_id uuid not null references public.users(id) on delete restrict, | ||
| reward_id uuid not null, |
There was a problem hiding this comment.
For the user relation, it makes more sense that the behavior should be on delete cascade. If a user is deleted, all of their claimed_rewards should also be deleted.
| reward_updated_at timestamptz not null, | ||
| claimed_at timestamptz not null, | ||
| foreign key (reward_id, reward_updated_at) references reward_snapshots(id, updated_at) on delete restrict | ||
| ); |
There was a problem hiding this comment.
Here, on delete restrict is good because we don't want to be able to delete snapshots unless all claimed rewards that reference them are deleted.
|
|
||
| create table vouchers ( | ||
| id serial primary key, | ||
| claimed_reward_id integer not null references claimed_rewards(id) on delete restrict, |
There was a problem hiding this comment.
Again, for this relation, on delete cascade makes more sense. If a claimed reward is deleted, all related vouchers should be deleted, too.
|
Before I push my new code do you mean enable RLS and indexing for all each table ? |
|
Yes, that is correct. I'm going to send you an updated ERD document with the latest changes I will need to request based on revisions to the main rewards system schema |
* upgraded next.js, executed npm audit fix, added react-confetti, supressed irrelevant warnings in test environment * upgraded jest version, fixed failing tests * removed dependency on node 18 from github actions test workflow, restored test coverage to 100% * removed lockfile and reinstalled packages * regenerated lockfile * diagnosing breaking tests in CI * updated node version to latest in test workflow * attempting to resolve failure of tests in ci environment * testing without overrides * attempting to resolve glob issue
Checklist
Overview
Test Plan
Follow ups