Skip to content

Commit

Permalink
Write to both DynamoDB and RDS (#1065)
Browse files Browse the repository at this point in the history
Co-authored-by: Douglas Hong <[email protected]>
Co-authored-by: Aponia <[email protected]>
Co-authored-by: Eddy Chen <[email protected]>
Co-authored-by: Isaac Nguyen <[email protected]>
  • Loading branch information
5 people authored Dec 6, 2024
1 parent 8b87112 commit a1b675e
Show file tree
Hide file tree
Showing 47 changed files with 6,518 additions and 4,751 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ env:
HOSTED_ZONE_ID: ${{ secrets.HOSTED_ZONE_ID }}
CERTIFICATE_ARN: ${{ secrets.CERTIFICATE_ARN }}
PR_NUM: ${{ github.event.pull_request.number }}
STAGE: prod

jobs:
# Build production version of the frontend and upload the artifacts.
Expand Down Expand Up @@ -112,6 +113,9 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile --prod false

- name: Run database migrations
run: pnpm --filter "antalmanac-backend" migrate

- name: Build backend
run: pnpm --filter "antalmanac-backend" build
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ env:
HOSTED_ZONE_ID: ${{ secrets.HOSTED_ZONE_ID }}
CERTIFICATE_ARN: ${{ secrets.CERTIFICATE_ARN }}
PR_NUM: ${{ github.event.pull_request.number }}
STAGE: dev

jobs:
get_staging_configuration:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/destroy_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ env:
HOSTED_ZONE_ID: ${{ secrets.HOSTED_ZONE_ID }}
CERTIFICATE_ARN: ${{ secrets.CERTIFICATE_ARN }}
PR_NUM: ${{ github.event.pull_request.number }}
STAGE: dev

jobs:
destroy_staging_frontend:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ Desktop.ini

## VSCode settings.
.vscode/

## Turbo
.turbo/
1 change: 1 addition & 0 deletions apps/antalmanac/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"lint": "eslint src"
},
"dependencies": {
"@babel/runtime": "^7.26.0",
"@date-io/date-fns": "^2.16.0",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
Expand Down
35 changes: 16 additions & 19 deletions apps/antalmanac/src/components/PatchNotes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { getLocalStoragePatchNotesKey, setLocalStoragePatchNotesKey } from '$lib
*
* @example '20230819'
*/
export const latestPatchNotesUpdate = '20230819';
export const latestPatchNotesUpdate = '20241124';

/**
* Whether the user's last visited patch notes is outdated.
Expand Down Expand Up @@ -53,30 +53,27 @@ function PatchNotes() {
data-testid={dialogTestId}
slots={{ backdrop: PatchNotesBackdrop }}
>
<DialogTitle>{"What's New - October 2023"}</DialogTitle>
<DialogTitle>{"What's New - November 2024"}</DialogTitle>

<DialogContent>
<Typography>Features</Typography>
<Typography>Migration</Typography>
<ul>
<li>We are migrating our database to support exciting features coming this year!</li>
<li>
You can now hover over the Zotistics button to see the Zotistics graph! On mobile, you can still
click the Zotistics button to toggle the graph.
If you experience issues with saving and retrieving schedules, please let us know by filling out
the{' '}
<a href="https://docs.google.com/forms/d/e/1FAIpQLSe0emRHqog-Ctl8tjZfJvewY_CSGXys8ykBkFBy1EEUUUHbUw/viewform">
feedback form
</a>
.
</li>
</ul>
<img
src="https://user-images.githubusercontent.com/78244965/277567417-f9816b9d-ddda-4c0f-80f4-eeac92428612.gif"
alt="(gif of the new feature)"
style={{
maxWidth: '100%',
boxShadow: '4px 4px 4px rgba(0, 0, 0, 0.4)',
}}
/>
<br />
Remember to use the{' '}
<a href="https://docs.google.com/forms/d/e/1FAIpQLSe0emRHqog-Ctl8tjZfJvewY_CSGXys8ykBkFBy1EEUUUHbUw/viewform">
feedback form
</a>{' '}
to let us know what you think!

<Typography>Features</Typography>
<ul>
<li>Search now contains all new classes and will update automatically!</li>
<li>Many bug fixes and quality-of-life improvements</li>
</ul>
</DialogContent>

<DialogActions>
Expand Down
14 changes: 14 additions & 0 deletions apps/backend/drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from "drizzle-kit";

import { rdsEnvSchema } from "./src/env";

const { DB_URL } = rdsEnvSchema.parse(process.env);

export default defineConfig({
dialect: "postgresql",
schema: "./src/db/schema/index.ts",
out: "./drizzle",
dbCredentials: {
url: DB_URL,
}
});
103 changes: 103 additions & 0 deletions apps/backend/drizzle/0000_rapid_speed_demon.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
CREATE TYPE "public"."account_type" AS ENUM('GOOGLE', 'GUEST');--> statement-breakpoint
CREATE TYPE "public"."subscription_target_status" AS ENUM('OPEN', 'WAITLISTED');--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "accounts" (
"user_id" text NOT NULL,
"account_type" "account_type" NOT NULL,
"provider_account_id" text NOT NULL,
CONSTRAINT "accounts_user_id_account_type_pk" PRIMARY KEY("user_id","account_type")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "sessions" (
"id" text PRIMARY KEY NOT NULL,
"user_id" text NOT NULL,
"expires" timestamp NOT NULL,
"refresh_token" text
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "users" (
"id" text PRIMARY KEY NOT NULL,
"phone" text,
"avatar" text,
"name" text,
"current_schedule_id" text,
"last_updated" timestamp with time zone DEFAULT now()
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "schedules" (
"id" text PRIMARY KEY NOT NULL,
"user_id" text NOT NULL,
"name" text,
"notes" text,
"last_updated" timestamp with time zone NOT NULL,
CONSTRAINT "schedules_user_id_name_unique" UNIQUE("user_id","name")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "coursesInSchedule" (
"scheduleId" text NOT NULL,
"sectionCode" integer NOT NULL,
"term" text NOT NULL,
"color" text NOT NULL,
"last_updated" timestamp with time zone DEFAULT now(),
CONSTRAINT "coursesInSchedule_scheduleId_sectionCode_term_pk" PRIMARY KEY("scheduleId","sectionCode","term")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "customEvents" (
"id" text PRIMARY KEY NOT NULL,
"scheduleId" text NOT NULL,
"title" text NOT NULL,
"start" text NOT NULL,
"end" text NOT NULL,
"days" text NOT NULL,
"color" text,
"building" text,
"last_updated" timestamp with time zone DEFAULT now()
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "subscriptions" (
"userId" text,
"sectionCode" integer,
"status" "subscription_target_status",
CONSTRAINT "subscriptions_userId_sectionCode_pk" PRIMARY KEY("userId","sectionCode")
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "accounts" ADD CONSTRAINT "accounts_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "users" ADD CONSTRAINT "users_current_schedule_id_schedules_id_fk" FOREIGN KEY ("current_schedule_id") REFERENCES "public"."schedules"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "schedules" ADD CONSTRAINT "schedules_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "coursesInSchedule" ADD CONSTRAINT "coursesInSchedule_scheduleId_schedules_id_fk" FOREIGN KEY ("scheduleId") REFERENCES "public"."schedules"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "customEvents" ADD CONSTRAINT "customEvents_scheduleId_schedules_id_fk" FOREIGN KEY ("scheduleId") REFERENCES "public"."schedules"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "subscriptions" ADD CONSTRAINT "subscriptions_userId_users_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
2 changes: 2 additions & 0 deletions apps/backend/drizzle/0001_powerful_tiger_shark.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE "schedules" ADD COLUMN "index" integer NOT NULL;--> statement-breakpoint
ALTER TABLE "schedules" ADD CONSTRAINT "schedules_user_id_index_unique" UNIQUE("user_id","index");
7 changes: 7 additions & 0 deletions apps/backend/drizzle/0002_fat_ted_forrester.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ALTER TABLE "users" DROP CONSTRAINT "users_current_schedule_id_schedules_id_fk";
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "users" ADD CONSTRAINT "users_current_schedule_id_schedules_id_fk" FOREIGN KEY ("current_schedule_id") REFERENCES "public"."schedules"("id") ON DELETE set null ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
Loading

0 comments on commit a1b675e

Please sign in to comment.