Skip to content

Commit 2b22cbe

Browse files
authored
Merge pull request #261 from DestinyItemManager/remove-postgres
Remove all postgres code
2 parents 218d251 + 5befaa2 commit 2b22cbe

File tree

71 files changed

+32
-4585
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+32
-4585
lines changed

.env

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
1-
PGHOST=localhost
2-
PGPORT=31744
3-
PGDATABASE=postgres
4-
PGUSER=postgresadmin
5-
PGPASSWORD=dsjdsFwqklqwkbj
61
JWT_SECRET=dummysecret
7-
PGSSL=false
82
VHOST=api.destinyitemmanager.com

.github/workflows/deploy.yml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,6 @@ jobs:
5050
- name: Save DigitalOcean kubeconfig with short-lived credentials
5151
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{secrets.K8S_CLUSTER}}
5252

53-
- name: Add IP address to trusted source (managed database)
54-
uses: GarreauArthur/manage-digital-ocean-managed-database-trusted-sources-gh-action@main
55-
with:
56-
action: 'add'
57-
database_id: ${{ secrets.DATABASE_ID }}
58-
digitalocean_token: ${{ secrets.DIGITALOCEAN_TOKEN }}
59-
60-
- name: Run DB migrations
61-
run: cd api && npx db-migrate up -e prod
62-
env:
63-
DATABASE_USER: ${{ secrets.DATABASE_USER }}
64-
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
65-
DATABASE_HOST: ${{ secrets.DATABASE_HOST }}
66-
DATABASE_NAME: ${{ secrets.DATABASE_NAME }}
67-
DATABASE_PORT: ${{ secrets.DATABASE_PORT }}
68-
69-
- name: Remove IP address to trusted source (managed database)
70-
if: always()
71-
continue-on-error: true
72-
uses: GarreauArthur/manage-digital-ocean-managed-database-trusted-sources-gh-action@main
73-
with:
74-
action: 'remove'
75-
database_id: ${{ secrets.DATABASE_ID }}
76-
digitalocean_token: ${{ secrets.DIGITALOCEAN_TOKEN }}
77-
7853
- name: Build and deploy
7954
run: pnpm run deploy
8055

.github/workflows/pr-build.yml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,6 @@ jobs:
99
runs-on: ubuntu-latest
1010
environment: 'test'
1111

12-
services:
13-
postgres:
14-
# Docker Hub image
15-
image: nat212/postgres-cron
16-
# Provide the password for postgres
17-
env:
18-
POSTGRES_USER: postgres
19-
POSTGRES_PASSWORD: postgres
20-
POSTGRES_DB: travis_ci_test
21-
POSTGRES_CRON_DB: travis_ci_test
22-
ports:
23-
- 5432:5432
24-
# Set health checks to wait until postgres has started
25-
options: >-
26-
--health-cmd pg_isready
27-
--health-interval 10s
28-
--health-timeout 5s
29-
--health-retries 5
30-
3112
steps:
3213
- uses: actions/checkout@v4
3314

@@ -42,12 +23,6 @@ jobs:
4223
- name: Install
4324
run: pnpm install --frozen-lockfile --prefer-offline
4425

45-
- name: Migrate Test DB
46-
run: |
47-
pushd api
48-
npx db-migrate up -e test
49-
popd
50-
5126
- run: cp build/.env.travis .env
5227

5328
- name: Build API

api/apps/index.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import * as Sentry from '@sentry/node';
22
import { ListToken } from '@stately-cloud/client';
33
import { keyBy } from 'es-toolkit';
44
import { RequestHandler } from 'express';
5-
import { getAllApps as getAllAppsPostgres } from '../db/apps-queries.js';
6-
import { pool } from '../db/index.js';
75
import { metrics } from '../metrics/index.js';
86
import { ApiApp } from '../shapes/app.js';
97
import { getAllApps, updateApps } from '../stately/apps-queries.js';
@@ -72,13 +70,6 @@ export async function refreshApps(): Promise<void> {
7270
stopAppsRefresh();
7371

7472
try {
75-
if (apps.length === 0) {
76-
// Start off with a copy from postgres, just in case StatelyDB is having
77-
// problems.
78-
await fetchAppsFromPostgres();
79-
digestApps();
80-
}
81-
8273
if (!token) {
8374
// First time, get 'em all
8475
const [appsFromStately, newToken] = await getAllApps();
@@ -110,21 +101,6 @@ export async function refreshApps(): Promise<void> {
110101
}
111102
}
112103

113-
async function fetchAppsFromPostgres() {
114-
const client = await pool.connect();
115-
try {
116-
apps = await getAllAppsPostgres(client);
117-
appsByApiKey = keyBy(apps, (a) => a.dimApiKey.toLowerCase());
118-
origins = new Set<string>();
119-
for (const app of apps) {
120-
origins.add(app.origin);
121-
}
122-
return apps;
123-
} finally {
124-
client.release();
125-
}
126-
}
127-
128104
function digestApps() {
129105
appsByApiKey = keyBy(apps, (a) => a.dimApiKey.toLowerCase());
130106
origins = new Set<string>();

api/db/apps-queries.test.ts

Lines changed: 0 additions & 52 deletions
This file was deleted.

api/db/apps-queries.ts

Lines changed: 0 additions & 42 deletions
This file was deleted.

api/db/index.test.ts

Lines changed: 0 additions & 96 deletions
This file was deleted.

api/db/index.ts

Lines changed: 0 additions & 75 deletions
This file was deleted.

0 commit comments

Comments
 (0)