-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(points): add !points undo (#3593)
* feat(points): add !points undo Fixes #3590 * fixup * fix * cleanup points changelog
- Loading branch information
Showing
10 changed files
with
338 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { EntitySchema } from 'typeorm'; | ||
import { ColumnNumericTransformer } from './_transformer'; | ||
|
||
export interface PointsChangelogInterface { | ||
id: number; | ||
userId: number; | ||
originalValue: number; | ||
updatedValue: number; | ||
updatedAt: number; | ||
command: 'set' | 'add' | 'remove'; | ||
} | ||
|
||
export const PointsChangelog = new EntitySchema<Readonly<Required<PointsChangelogInterface>>>({ | ||
name: 'points_changelog', | ||
columns: { | ||
id: { type: Number, primary: true, generated: 'increment' }, | ||
userId: { type: Number }, | ||
originalValue: { type: Number }, | ||
updatedValue: { type: Number }, | ||
updatedAt: { type: 'bigint', transformer: new ColumnNumericTransformer() }, | ||
command: { type: String }, | ||
}, | ||
indices: [ | ||
{ name: 'IDX_points_changelog_userId', columns: ['userId'] }, | ||
], | ||
}); |
15 changes: 15 additions & 0 deletions
15
src/bot/database/migration/mysql/1587985735225-pointsChangelog.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {MigrationInterface, QueryRunner} from 'typeorm'; | ||
|
||
export class pointsChangelog1587985735225 implements MigrationInterface { | ||
name = 'pointsChangelog1587985735225'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query('CREATE TABLE `points_changelog` (`id` int NOT NULL AUTO_INCREMENT, `userId` int NOT NULL, `originalValue` int NOT NULL, `updatedValue` int NOT NULL, `updatedAt` bigint NOT NULL, `command` varchar(255) NOT NULL, INDEX `IDX_points_changelog_userId` (`userId`), PRIMARY KEY (`id`)) ENGINE=InnoDB', undefined); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query('DROP INDEX `IDX_points_changelog_userId` ON `points_changelog`', undefined); | ||
await queryRunner.query('DROP TABLE `points_changelog`', undefined); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
src/bot/database/migration/postgres/1587985404134-pointsChangelog.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {MigrationInterface, QueryRunner} from 'typeorm'; | ||
|
||
export class pointsChangelog1587985404134 implements MigrationInterface { | ||
name = 'pointsChangelog1587985404134'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`CREATE TABLE "points_changelog" ("id" SERIAL NOT NULL, "userId" integer NOT NULL, "originalValue" integer NOT NULL, "updatedValue" integer NOT NULL, "updatedAt" bigint NOT NULL, "command" character varying NOT NULL, CONSTRAINT "PK_0c0431424ad9af4002e606a5337" PRIMARY KEY ("id"))`, undefined); | ||
await queryRunner.query(`CREATE INDEX "IDX_points_changelog_userId" ON "points_changelog" ("userId") `, undefined); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP INDEX "IDX_points_changelog_userId"`, undefined); | ||
await queryRunner.query(`DROP TABLE "points_changelog"`, undefined); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
src/bot/database/migration/sqlite/1587985914346-pointsChangelog.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {MigrationInterface, QueryRunner} from 'typeorm'; | ||
|
||
export class pointsChangelog1587985914346 implements MigrationInterface { | ||
name = 'pointsChangelog1587985914346'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`CREATE TABLE "points_changelog" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "userId" integer NOT NULL, "originalValue" integer NOT NULL, "updatedValue" integer NOT NULL, "updatedAt" bigint NOT NULL, "command" varchar NOT NULL)`, undefined); | ||
await queryRunner.query(`CREATE INDEX "IDX_points_changelog_userId" ON "points_changelog" ("userId") `, undefined); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP INDEX "IDX_points_changelog_userId"`, undefined); | ||
await queryRunner.query(`DROP TABLE "points_changelog"`, undefined); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.