Skip to content

Commit

Permalink
Merge pull request #73 from sgcarstrends/72-migrate-to-postgres-neon
Browse files Browse the repository at this point in the history
Migrate to Postgres (Neon)
  • Loading branch information
ruchernchong authored Dec 23, 2024
2 parents d5e961e + b5671c8 commit cfe4cd8
Show file tree
Hide file tree
Showing 24 changed files with 1,434 additions and 256 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CLOUDFLARE_API_TOKEN=
MONGODB_URI=
DATABASE_URL=
SG_CARS_TRENDS_API_TOKEN=

UPSTASH_REDIS_REST_URL=
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/sst.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ on:
workflow_call:
inputs:
environment:
description: 'GitHub environment name'
description: "GitHub environment name"
required: true
type: string
sst-stage:
description: 'SST deployment stage'
description: "SST deployment stage"
required: true
type: string
secrets:
CLOUDFLARE_API_TOKEN:
required: true
DATABASE_URL:
required: true
MONGODB_URI:
required: true
SG_CARS_TRENDS_API_TOKEN:
Expand All @@ -29,6 +31,7 @@ jobs:
environment: ${{ inputs.environment }}
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
MONGODB_URI: ${{ secrets.MONGODB_URI }}
SG_CARS_TRENDS_API_TOKEN: ${{ secrets.SG_CARS_TRENDS_API_TOKEN }}
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
Expand All @@ -51,7 +54,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: latest
cache: 'pnpm'
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- uses: aws-actions/configure-aws-credentials@v4
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/sst.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ name: Deployment (Dev)
on:
push:
branches-ignore:
- 'main'
- 'release/**'

- "main"
- "release/**"

permissions:
id-token: write
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sst.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Deployment (Prod)
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+"

permissions:
id-token: write
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sst.staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Deployment (Staging)
on:
push:
branches:
- 'main'
- 'release/**'
- "main"
- "release/**"
tags-ignore:
- '*'
- "*"

permissions:
id-token: write
Expand Down
10 changes: 10 additions & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "drizzle-kit";

export default defineConfig({
schema: "./src/schema.ts",
out: "./migrations",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL,
},
});
37 changes: 37 additions & 0 deletions migrations/0000_keen_guardian.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
-- Current sql file was generated after introspecting the database
-- If you want to run this migration please uncomment this code before executing migrations
/*
CREATE TABLE "cars" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"month" text,
"make" text,
"importer_type" text,
"fuel_type" text,
"vehicle_type" text,
"number" integer
);
--> statement-breakpoint
CREATE TABLE "coe" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"month" text,
"bidding_no" integer,
"vehicle_class" text,
"quota" integer,
"bids_success" integer,
"bids_received" integer,
"premium" integer
);
--> statement-breakpoint
CREATE INDEX "fuel_type_idx" ON "cars" USING btree ("fuel_type" text_ops);--> statement-breakpoint
CREATE INDEX "make_fuel_type_idx" ON "cars" USING btree ("make" text_ops,"fuel_type" text_ops);--> statement-breakpoint
CREATE INDEX "make_idx" ON "cars" USING btree ("make" text_ops);--> statement-breakpoint
CREATE INDEX "month_idx" ON "cars" USING btree ("month" text_ops);--> statement-breakpoint
CREATE INDEX "month_make_idx" ON "cars" USING btree ("month" text_ops,"make" text_ops);--> statement-breakpoint
CREATE INDEX "number_idx" ON "cars" USING btree ("number" int4_ops);--> statement-breakpoint
CREATE INDEX "bids_idx" ON "coe" USING btree ("bids_success" int4_ops,"bids_received" int4_ops);--> statement-breakpoint
CREATE INDEX "month_bidding_no_idx" ON "coe" USING btree ("month" text_ops,"bidding_no" int4_ops);--> statement-breakpoint
CREATE INDEX "month_bidding_no_vehicle_class_idx" ON "coe" USING btree ("month" int4_ops,"bidding_no" int4_ops,"vehicle_class" text_ops);--> statement-breakpoint
CREATE INDEX "month_vehicle_idx" ON "coe" USING btree ("month" text_ops,"vehicle_class" text_ops);--> statement-breakpoint
CREATE INDEX "premium_idx" ON "coe" USING btree ("premium" int4_ops);--> statement-breakpoint
CREATE INDEX "vehicle_class_idx" ON "coe" USING btree ("vehicle_class" text_ops);
*/
Loading

0 comments on commit cfe4cd8

Please sign in to comment.