Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all postgres code #261

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .env
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
PGHOST=localhost
PGPORT=31744
PGDATABASE=postgres
PGUSER=postgresadmin
PGPASSWORD=dsjdsFwqklqwkbj
JWT_SECRET=dummysecret
PGSSL=false
VHOST=api.destinyitemmanager.com
25 changes: 0 additions & 25 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,6 @@ jobs:
- name: Save DigitalOcean kubeconfig with short-lived credentials
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{secrets.K8S_CLUSTER}}

- name: Add IP address to trusted source (managed database)
uses: GarreauArthur/manage-digital-ocean-managed-database-trusted-sources-gh-action@main
with:
action: 'add'
database_id: ${{ secrets.DATABASE_ID }}
digitalocean_token: ${{ secrets.DIGITALOCEAN_TOKEN }}

- name: Run DB migrations
run: cd api && npx db-migrate up -e prod
env:
DATABASE_USER: ${{ secrets.DATABASE_USER }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
DATABASE_HOST: ${{ secrets.DATABASE_HOST }}
DATABASE_NAME: ${{ secrets.DATABASE_NAME }}
DATABASE_PORT: ${{ secrets.DATABASE_PORT }}

- name: Remove IP address to trusted source (managed database)
if: always()
continue-on-error: true
uses: GarreauArthur/manage-digital-ocean-managed-database-trusted-sources-gh-action@main
with:
action: 'remove'
database_id: ${{ secrets.DATABASE_ID }}
digitalocean_token: ${{ secrets.DIGITALOCEAN_TOKEN }}

- name: Build and deploy
run: pnpm run deploy

Expand Down
25 changes: 0 additions & 25 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,6 @@ jobs:
runs-on: ubuntu-latest
environment: 'test'

services:
postgres:
# Docker Hub image
image: nat212/postgres-cron
# Provide the password for postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: travis_ci_test
POSTGRES_CRON_DB: travis_ci_test
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v4

Expand All @@ -42,12 +23,6 @@ jobs:
- name: Install
run: pnpm install --frozen-lockfile --prefer-offline

- name: Migrate Test DB
run: |
pushd api
npx db-migrate up -e test
popd

- run: cp build/.env.travis .env

- name: Build API
Expand Down
24 changes: 0 additions & 24 deletions api/apps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import * as Sentry from '@sentry/node';
import { ListToken } from '@stately-cloud/client';
import { keyBy } from 'es-toolkit';
import { RequestHandler } from 'express';
import { getAllApps as getAllAppsPostgres } from '../db/apps-queries.js';
import { pool } from '../db/index.js';
import { metrics } from '../metrics/index.js';
import { ApiApp } from '../shapes/app.js';
import { getAllApps, updateApps } from '../stately/apps-queries.js';
Expand Down Expand Up @@ -72,13 +70,6 @@ export async function refreshApps(): Promise<void> {
stopAppsRefresh();

try {
if (apps.length === 0) {
// Start off with a copy from postgres, just in case StatelyDB is having
// problems.
await fetchAppsFromPostgres();
digestApps();
}

if (!token) {
// First time, get 'em all
const [appsFromStately, newToken] = await getAllApps();
Expand Down Expand Up @@ -110,21 +101,6 @@ export async function refreshApps(): Promise<void> {
}
}

async function fetchAppsFromPostgres() {
const client = await pool.connect();
try {
apps = await getAllAppsPostgres(client);
appsByApiKey = keyBy(apps, (a) => a.dimApiKey.toLowerCase());
origins = new Set<string>();
for (const app of apps) {
origins.add(app.origin);
}
return apps;
} finally {
client.release();
}
}

function digestApps() {
appsByApiKey = keyBy(apps, (a) => a.dimApiKey.toLowerCase());
origins = new Set<string>();
Expand Down
52 changes: 0 additions & 52 deletions api/db/apps-queries.test.ts

This file was deleted.

42 changes: 0 additions & 42 deletions api/db/apps-queries.ts

This file was deleted.

96 changes: 0 additions & 96 deletions api/db/index.test.ts

This file was deleted.

75 changes: 0 additions & 75 deletions api/db/index.ts

This file was deleted.

Loading
Loading