mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-22 08:40:03 +01:00
b89a2f8e28
* refactor: rename Graphile to Graphile Worker * revert env var changes * one more * format readme * add changed files
26 lines
791 B
TypeScript
26 lines
791 B
TypeScript
import { makeWorkerUtils } from 'graphile-worker'
|
|
import { Pool } from 'pg'
|
|
|
|
import { PluginsServerConfig } from '../../src/types'
|
|
|
|
export async function resetGraphileWorkerSchema(serverConfig: PluginsServerConfig): Promise<void> {
|
|
const graphileUrl = serverConfig.JOB_QUEUE_GRAPHILE_URL || serverConfig.DATABASE_URL!
|
|
const db = new Pool({ connectionString: graphileUrl })
|
|
|
|
try {
|
|
await db.query('DROP SCHEMA graphile_worker CASCADE')
|
|
} catch (error) {
|
|
if (error.message !== 'schema "graphile_worker" does not exist') {
|
|
throw error
|
|
}
|
|
} finally {
|
|
await db.end()
|
|
}
|
|
|
|
const workerUtils = await makeWorkerUtils({
|
|
connectionString: graphileUrl,
|
|
})
|
|
await workerUtils.migrate()
|
|
await workerUtils.release()
|
|
}
|