Skip to content
Open
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
2 changes: 2 additions & 0 deletions api/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export {
EmbeddingSecretModelColumn,
} from '../src/db/models/new/embedding-secret';

export {JobOperationModel, JobOperationColumn} from '../src/db/models/new/job-operation';

export {ColorPaletteModel, ColorPaletteModelColumn} from '../src/db/models/new/color-palette';

export {
Expand Down
17 changes: 17 additions & 0 deletions src/db/migrations/20240730135215_add_job_operations_table.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type {Knex} from 'knex';

export async function up(knex: Knex): Promise<void> {
return knex.raw(`
CREATE TABLE job_operations (
operation_id BIGINT DEFAULT get_id() PRIMARY KEY,
current_job_id VARCHAR(255),
meta JSONB NOT NULL DEFAULT '{}'::jsonb
);
`);
}

export async function down(knex: Knex): Promise<void> {
return knex.raw(`
DROP TABLE job_operations;
`);
}
21 changes: 21 additions & 0 deletions src/db/models/new/job-operation/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {Model} from '../../..';

export const JobOperationColumn = {
OperationId: 'operationId',
CurrentJobId: 'currentJobId',
Meta: 'meta',
} as const;

export class JobOperationModel extends Model {
static get tableName() {
return 'job_operations';
}

static get idColumn() {
return JobOperationColumn.OperationId;
}

[JobOperationColumn.OperationId]!: string;
[JobOperationColumn.CurrentJobId]!: Nullable<string>;
[JobOperationColumn.Meta]!: Record<string, unknown>;
}