From 2bce901d63de491f42e3aa75b1a3617e12c22394 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Fri, 26 Apr 2024 18:35:03 +0100 Subject: [PATCH] Create concept of currency in the database (#209) # Description Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. - Create the concept of currency in the database #200 ## Type of change Please delete options that are not relevant. - [x] New feature (non-breaking change which adds functionality) # How Has This Been Tested? Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration. # Checklist - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that provde my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/209 Reviewed-by: VylpesTester Co-authored-by: Ethan Lane Co-committed-by: Ethan Lane --- .../1713289062969-user/Up/01-table/User.sql | 7 +++++++ src/database/entities/app/User.ts | 19 +++++++++++++++++++ .../migrations/app/0.6/1713289062969-user.ts | 15 +++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 database/0.6/1713289062969-user/Up/01-table/User.sql create mode 100644 src/database/entities/app/User.ts create mode 100644 src/database/migrations/app/0.6/1713289062969-user.ts diff --git a/database/0.6/1713289062969-user/Up/01-table/User.sql b/database/0.6/1713289062969-user/Up/01-table/User.sql new file mode 100644 index 0000000..86a5d36 --- /dev/null +++ b/database/0.6/1713289062969-user/Up/01-table/User.sql @@ -0,0 +1,7 @@ +CREATE TABLE `user` ( + `Id` varchar(255) NOT NULL, + `WhenCreated` datetime NOT NULL, + `WhenUpdated` datetime NOT NULL, + `Currency` int NOT NULL, + PRIMARY KEY (`Id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; \ No newline at end of file diff --git a/src/database/entities/app/User.ts b/src/database/entities/app/User.ts new file mode 100644 index 0000000..c954aea --- /dev/null +++ b/src/database/entities/app/User.ts @@ -0,0 +1,19 @@ +import { Column, Entity } from "typeorm"; +import AppBaseEntity from "../../../contracts/AppBaseEntity"; + +@Entity() +export default class User extends AppBaseEntity { + constructor(userId: string, currency: number) { + super(); + + this.Id = userId; + this.Currency = currency; + } + + @Column() + Currency: number; + + public UpdateCurrency(currency: number) { + this.Currency = currency; + } +} \ No newline at end of file diff --git a/src/database/migrations/app/0.6/1713289062969-user.ts b/src/database/migrations/app/0.6/1713289062969-user.ts new file mode 100644 index 0000000..151db88 --- /dev/null +++ b/src/database/migrations/app/0.6/1713289062969-user.ts @@ -0,0 +1,15 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; +import MigrationHelper from "../../../../helpers/MigrationHelper"; + +export class User1713289062969 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + MigrationHelper.Up("1713289062969-user", "0.6", [ + "01-table/User", + ], queryRunner); + } + + public async down(): Promise { + } + +}