From 21ca26dcfee4fe4fb846068057241ac348a934c6 Mon Sep 17 00:00:00 2001 From: Hachi-R Date: Fri, 8 Nov 2024 17:30:18 -0300 Subject: [PATCH] feat: update schema with seeding columns --- src/main/entity/game.entity.ts | 3 +++ src/main/entity/user-preferences.entity.ts | 3 +++ src/main/knex-client.ts | 4 ++++ .../20241108200154_add_should_seed_colum.ts | 17 ++++++++++++++++ .../20241108201806_add_seed_after_download.ts | 20 +++++++++++++++++++ src/types/index.ts | 2 ++ 6 files changed, 49 insertions(+) create mode 100644 src/main/migrations/20241108200154_add_should_seed_colum.ts create mode 100644 src/main/migrations/20241108201806_add_seed_after_download.ts diff --git a/src/main/entity/game.entity.ts b/src/main/entity/game.entity.ts index 19905c32..baa6355c 100644 --- a/src/main/entity/game.entity.ts +++ b/src/main/entity/game.entity.ts @@ -85,6 +85,9 @@ export class Game { @Column("boolean", { default: false }) isDeleted: boolean; + @Column("boolean", { default: false }) + shouldSeed: boolean; + @CreateDateColumn() createdAt: Date; diff --git a/src/main/entity/user-preferences.entity.ts b/src/main/entity/user-preferences.entity.ts index 357dfb50..24cfcc8f 100644 --- a/src/main/entity/user-preferences.entity.ts +++ b/src/main/entity/user-preferences.entity.ts @@ -41,6 +41,9 @@ export class UserPreferences { @Column("boolean", { default: false }) disableNsfwAlert: boolean; + @Column("boolean", { default: true }) + seedAfterDownloadComplete: boolean; + @CreateDateColumn() createdAt: Date; diff --git a/src/main/knex-client.ts b/src/main/knex-client.ts index 988d42da..188fa2a5 100644 --- a/src/main/knex-client.ts +++ b/src/main/knex-client.ts @@ -13,6 +13,8 @@ import { AddBackgroundImageUrl } from "./migrations/20241016100249_add_backgroun import { AddWinePrefixToGame } from "./migrations/20241019081648_add_wine_prefix_to_game"; import { AddStartMinimizedColumn } from "./migrations/20241030171454_add_start_minimized_column"; import { AddDisableNsfwAlertColumn } from "./migrations/20241106053733_add_disable_nsfw_alert_column"; +import { AddShouldSeedColumn } from "./migrations/20241108200154_add_should_seed_colum"; +import { AddSeedAfterDownloadColumn } from "./migrations/20241108201806_add_seed_after_download"; export type HydraMigration = Knex.Migration & { name: string }; class MigrationSource implements Knex.MigrationSource { @@ -30,6 +32,8 @@ class MigrationSource implements Knex.MigrationSource { AddWinePrefixToGame, AddStartMinimizedColumn, AddDisableNsfwAlertColumn, + AddShouldSeedColumn, + AddSeedAfterDownloadColumn, ]); } getMigrationName(migration: HydraMigration): string { diff --git a/src/main/migrations/20241108200154_add_should_seed_colum.ts b/src/main/migrations/20241108200154_add_should_seed_colum.ts new file mode 100644 index 00000000..60be0730 --- /dev/null +++ b/src/main/migrations/20241108200154_add_should_seed_colum.ts @@ -0,0 +1,17 @@ +import type { HydraMigration } from "@main/knex-client"; +import type { Knex } from "knex"; + +export const AddShouldSeedColumn: HydraMigration = { + name: "AddShouldSeedColumn", + up: (knex: Knex) => { + return knex.schema.alterTable("game", (table) => { + return table.boolean("shouldSeed").notNullable().defaultTo(false); + }); + }, + + down: async (knex: Knex) => { + return knex.schema.alterTable("game", (table) => { + return table.dropColumn("shouldSeed"); + }); + }, +}; diff --git a/src/main/migrations/20241108201806_add_seed_after_download.ts b/src/main/migrations/20241108201806_add_seed_after_download.ts new file mode 100644 index 00000000..75b94577 --- /dev/null +++ b/src/main/migrations/20241108201806_add_seed_after_download.ts @@ -0,0 +1,20 @@ +import type { HydraMigration } from "@main/knex-client"; +import type { Knex } from "knex"; + +export const AddSeedAfterDownloadColumn: HydraMigration = { + name: "AddSeedAfterDownloadColumn", + up: (knex: Knex) => { + return knex.schema.alterTable("user_preferences", (table) => { + return table + .boolean("seedAfterDownloadComplete") + .notNullable() + .defaultTo(true); + }); + }, + + down: async (knex: Knex) => { + return knex.schema.alterTable("user_preferences", (table) => { + return table.dropColumn("seedAfterDownloadComplete"); + }); + }, +}; diff --git a/src/types/index.ts b/src/types/index.ts index c0269cd3..9116a998 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -124,6 +124,7 @@ export interface Game { objectID: string; shop: GameShop; downloadQueue: DownloadQueue | null; + shouldSeed: boolean; createdAt: Date; updatedAt: Date; } @@ -162,6 +163,7 @@ export interface UserPreferences { runAtStartup: boolean; startMinimized: boolean; disableNsfwAlert: boolean; + seedAfterDownloadComplete: boolean; } export interface Steam250Game {