Create concept of currency in the database #209

Merged
Vylpes merged 4 commits from feature/200-currency-db into develop 2024-04-26 18:35:03 +01:00
3 changed files with 41 additions and 0 deletions

View file

@ -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;

View file

@ -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;
Vylpes marked this conversation as resolved
Review

Would it be worth having this as the main primary key ID? I can't see that not being unique

Would it be worth having this as the main primary key ID? I can't see that not being unique
}
@Column()
Currency: number;
public UpdateCurrency(currency: number) {
this.Currency = currency;
}
}

View file

@ -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<void> {
MigrationHelper.Up("1713289062969-user", "0.6", [
"01-table/User",
], queryRunner);
}
public async down(): Promise<void> {
}
}