feat: adding background image migration

This commit is contained in:
Chubby Granny Chaser 2024-10-16 11:06:15 +01:00
parent 67109ff51a
commit a498f9dd80
No known key found for this signature in database
4 changed files with 23 additions and 0 deletions

View file

@ -22,6 +22,9 @@ export class UserAuth {
@Column("text", { nullable: true }) @Column("text", { nullable: true })
profileImageUrl: string | null; profileImageUrl: string | null;
@Column("text", { nullable: true })
backgroundImageUrl: string | null;
@Column("text", { default: "" }) @Column("text", { default: "" })
accessToken: string; accessToken: string;

View file

@ -18,6 +18,7 @@ const getMe = async (
id: 1, id: 1,
displayName: me.displayName, displayName: me.displayName,
profileImageUrl: me.profileImageUrl, profileImageUrl: me.profileImageUrl,
backgroundImageUrl: me.backgroundImageUrl,
userId: me.id, userId: me.id,
}, },
["id"] ["id"]

View file

@ -9,6 +9,7 @@ import { FixMissingColumns } from "./migrations/20240918001920_FixMissingColumns
import { CreateGameAchievement } from "./migrations/20240919030940_create_game_achievement"; import { CreateGameAchievement } from "./migrations/20240919030940_create_game_achievement";
import { AddAchievementNotificationPreference } from "./migrations/20241013012900_add_achievement_notification_preference"; import { AddAchievementNotificationPreference } from "./migrations/20241013012900_add_achievement_notification_preference";
import { CreateUserSubscription } from "./migrations/20241015235142_create_user_subscription"; import { CreateUserSubscription } from "./migrations/20241015235142_create_user_subscription";
import { AddBackgroundImageUrl } from "./migrations/20241016100249_add_background_image_url";
export type HydraMigration = Knex.Migration & { name: string }; export type HydraMigration = Knex.Migration & { name: string };
@ -23,6 +24,7 @@ class MigrationSource implements Knex.MigrationSource<HydraMigration> {
CreateGameAchievement, CreateGameAchievement,
AddAchievementNotificationPreference, AddAchievementNotificationPreference,
CreateUserSubscription, CreateUserSubscription,
AddBackgroundImageUrl,
]); ]);
} }
getMigrationName(migration: HydraMigration): string { getMigrationName(migration: HydraMigration): string {

View file

@ -0,0 +1,17 @@
import type { HydraMigration } from "@main/knex-client";
import type { Knex } from "knex";
export const AddBackgroundImageUrl: HydraMigration = {
name: "AddBackgroundImageUrl",
up: (knex: Knex) => {
return knex.schema.alterTable("user_auth", (table) => {
return table.text("backgroundImageUrl").nullable();
});
},
down: async (knex: Knex) => {
return knex.schema.alterTable("user_auth", (table) => {
return table.dropColumn("backgroundImageUrl");
});
},
};