From 36eef9807b47b9ba64343cc825c4d77172e2c1b3 Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Mon, 13 Jan 2025 20:38:11 -0500 Subject: [PATCH] fix: version history sql (#15321) --- server/src/queries/version.history.repository.sql | 8 ++++++++ server/src/repositories/version-history.repository.ts | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/server/src/queries/version.history.repository.sql b/server/src/queries/version.history.repository.sql index 2e898cac31..a9805e8c25 100644 --- a/server/src/queries/version.history.repository.sql +++ b/server/src/queries/version.history.repository.sql @@ -15,3 +15,11 @@ from "version_history" order by "createdAt" desc + +-- VersionHistoryRepository.create +insert into + "version_history" ("version") +values + ($1) +returning + * diff --git a/server/src/repositories/version-history.repository.ts b/server/src/repositories/version-history.repository.ts index a501687350..e6ec8edcf4 100644 --- a/server/src/repositories/version-history.repository.ts +++ b/server/src/repositories/version-history.repository.ts @@ -1,8 +1,8 @@ import { Injectable } from '@nestjs/common'; -import { Kysely } from 'kysely'; +import { Insertable, Kysely } from 'kysely'; import { InjectKysely } from 'nestjs-kysely'; -import { DB } from 'src/db'; -import { DummyValue, GenerateSql } from 'src/decorators'; +import { DB, VersionHistory } from 'src/db'; +import { GenerateSql } from 'src/decorators'; import { VersionHistoryEntity } from 'src/entities/version-history.entity'; import { IVersionHistoryRepository } from 'src/interfaces/version-history.interface'; @@ -20,8 +20,8 @@ export class VersionHistoryRepository implements IVersionHistoryRepository { return this.db.selectFrom('version_history').selectAll().orderBy('createdAt', 'desc').executeTakeFirst(); } - @GenerateSql({ params: [DummyValue.STRING] }) - create(version: Omit): Promise { + @GenerateSql({ params: [{ version: 'v1.123.0' }] }) + create(version: Insertable): Promise { return this.db.insertInto('version_history').values(version).returningAll().executeTakeFirstOrThrow(); } }