Skip to content

Commit

Permalink
update types
Browse files Browse the repository at this point in the history
  • Loading branch information
timgit committed Jul 18, 2024
1 parent 132ebb3 commit 6d3e066
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/contractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@ class Contractor {

// exported api to index
this.functions = [
this.version,
this.schemaVersion,
this.isInstalled
]
}

async version () {
async schemaVersion () {
const result = await this.db.executeSql(plans.getVersion(this.config.schema))
return result.rows.length ? parseInt(result.rows[0].version) : null
}

async isInstalled () {
const result = await this.db.executeSql(plans.versionTableExists(this.config.schema))
return result.rows.length ? result.rows[0].name : null
return !!result.rows[0].name
}

async start () {
const installed = await this.isInstalled()

if (installed) {
const version = await this.version()
const version = await this.schemaVersion()

if (schemaVersion > version) {
throw new Error('Migrations are not supported to v10')
Expand All @@ -61,7 +61,7 @@ class Contractor {
throw new Error('pg-boss is not installed')
}

const version = await this.version()
const version = await this.schemaVersion()

if (schemaVersion !== version) {
throw new Error('pg-boss database requires migrations')
Expand Down
8 changes: 5 additions & 3 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ declare class PgBoss extends EventEmitter {
getQueueSize(name: string, options?: object): Promise<number>;
getJobById(name: string, id: string, options?: PgBoss.ConnectionOptions): Promise<PgBoss.JobWithMetadata | null>;

createQueue(name: string, options?: Queue): Promise<void>;
getQueue(name: string): Promise<Queue | null>;
updateQueue(name: string, options?: QueueUpdateOptions): Promise<void>;
createQueue(name: string, options?: PgBoss.Queue): Promise<void>;
getQueue(name: string): Promise<PgBoss.Queue | null>;
updateQueue(name: string, options?: PgBoss.QueueUpdateOptions): Promise<void>;
deleteQueue(name: string): Promise<void>;
purgeQueue(name: string): Promise<void>;

Expand All @@ -361,6 +361,8 @@ declare class PgBoss extends EventEmitter {
purge(): Promise<void>;
expire(): Promise<void>;
maintain(): Promise<void>;
isInstalled(): Promise<Boolean>;
schemaVersion(): Promise<Number>;

schedule(name: string, cron: string, data?: object, options?: PgBoss.ScheduleOptions): Promise<void>;
unschedule(name: string): Promise<void>;
Expand Down

0 comments on commit 6d3e066

Please sign in to comment.