Skip to content

Commit

Permalink
Update banner
Browse files Browse the repository at this point in the history
  • Loading branch information
MadeBaruna committed Mar 13, 2024
1 parent edae93e commit f7c83f9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/entities/banner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Entity, Column, PrimaryColumn, OneToMany } from 'typeorm';
import { Pull } from './pull';
import { Wish } from './wish';

export type BannerType = 'beginners' | 'standard' | 'characters' | 'weapons';
export type BannerType = 'beginners' | 'standard' | 'characters' | 'weapons' | 'chronicled';

@Entity()
export class Banner {
Expand All @@ -14,7 +14,7 @@ export class Banner {

@Column({
type: 'enum',
enum: ['beginners', 'standard', 'characters', 'weapons'],
enum: ['beginners', 'standard', 'characters', 'weapons', 'chronicled'],
})
type: BannerType;

Expand Down
16 changes: 16 additions & 0 deletions src/migrations/1710312104956-UpdateBannerType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class UpdateBannerType1710312104956 implements MigrationInterface {
name = 'UpdateBannerType1710312104956';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('ALTER TYPE banner_type_enum ADD VALUE \'chronicled\'');
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('CREATE TYPE "banner_type_enum_old" AS ENUM(\'beginners\', \'standard\', \'characters\', \'weapons\')');
await queryRunner.query('ALTER TABLE "banner" ALTER COLUMN "type" TYPE "banner_type_enum_old" USING "type"::"text"::"banner_type_enum_old"');
await queryRunner.query('DROP TYPE "banner_type_enum"');
await queryRunner.query('ALTER TYPE "banner_type_enum_old" RENAME TO "banner_type_enum"');
}
}
26 changes: 26 additions & 0 deletions src/migrations/1710312547170-UpdateBanner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { Banner } from '../entities/banner';

const banner = {
name: 'Ode to the Dawn Breeze',
start: '2024-03-13 06:00:00',
end: '2024-04-02 17:59:00',
id: 500001,
};

export class UpdateBanner1710312547170 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const newBanner = new Banner();
newBanner.id = banner.id;
newBanner.type = 'chronicled';
newBanner.name = banner.name;
newBanner.start = `${banner.start}+8`;
newBanner.end = `${banner.end}+8`;

await queryRunner.manager.save(newBanner);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.manager.delete(Banner, [500001]);
}
}

0 comments on commit f7c83f9

Please sign in to comment.