Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Jun 11, 2024
1 parent 5b8a082 commit 6f574ac
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 42 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ jobs:
with:
node-version: 20
- run: npm ci
- run: npm run migrate
- run: npm test

build-observer:
Expand Down Expand Up @@ -63,7 +62,6 @@ jobs:
with:
node-version: 20
- run: npm ci
- run: npm run migrate
- run: npm test

lint-all:
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ Next, you need to create `spark_evaluate` database.
psql postgres://localhost:5432/ -c "CREATE DATABASE spark_evaluate"
```

Finally, run database schema migration scripts.

```bash
npm run migrate
```

### Run the test suite

```sh
Expand Down
21 changes: 16 additions & 5 deletions common/db.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { migrateWithPgClient } from '@filecoin-station/spark-stats-db-migrations'
import pg from 'pg'
import { migrateWithPgClient as migrateEvaluateDB } from 'spark-evaluate/lib/migrate.js'
import { migrateWithPgClient as migrateStatsDB } from '@filecoin-station/spark-stats-db-migrations'

const {
// DATABASE_URL points to `spark_stats` database managed by this monorepo
Expand Down Expand Up @@ -37,7 +38,7 @@ export const getStats = async () => {
connectionString: DATABASE_URL
})
stats.on('error', onError)
await migrateWithPgClient(stats)
await migrateStatsDB(stats)
return stats
}

Expand All @@ -47,9 +48,7 @@ export const getEvaluate = async () => {
connectionString: EVALUATE_DB_URL
})
evaluate.on('error', onError)

// Check that we can talk to the database
await evaluate.query('SELECT 1')
await migrateEvaluateDB(evaluate)
return evaluate
}

Expand All @@ -63,3 +62,15 @@ export const getPgPools = async () => {

return { stats, evaluate, end }
}

export const migrate = async () => {
const pgPools = await getPgPools()

console.log('Migrating spark_evaluate database')
await migrateEvaluateDB(pgPools.evaluate)

console.log('Migrating spark_stats database')
await migrateStatsDB(pgPools.stats)

await pgPools.end()
}
13 changes: 0 additions & 13 deletions observer/bin/migrate.js

This file was deleted.

1 change: 0 additions & 1 deletion observer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"type": "module",
"private": true,
"scripts": {
"migrate": "node bin/migrate.js",
"start": "node bin/spark-observer.js",
"lint": "standard",
"test": "mocha"
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"stats"
],
"scripts": {
"migrate": "npm run migrate --workspaces --if-present",
"lint": "standard",
"test:observer": "npm t -w observer",
"test:stats": "npm t -w stats",
Expand Down
13 changes: 0 additions & 13 deletions stats/bin/migrate.js

This file was deleted.

1 change: 0 additions & 1 deletion stats/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"type": "module",
"private": true,
"scripts": {
"migrate": "node bin/migrate.js",
"start": "node bin/spark-stats.js",
"lint": "standard",
"test": "mocha"
Expand Down

0 comments on commit 6f574ac

Please sign in to comment.