typing and db types
This commit is contained in:
parent
e455b5c8f6
commit
5fdfdcbd1f
9 changed files with 70 additions and 43 deletions
|
@ -8,7 +8,7 @@ export class communication {
|
|||
id: number;
|
||||
|
||||
@Column({ type: "boolean", default: false })
|
||||
preffered: boolean;
|
||||
preferred: boolean;
|
||||
|
||||
@Column({ type: "varchar", length: 255 })
|
||||
mobile: string;
|
||||
|
|
|
@ -11,7 +11,19 @@ export class member {
|
|||
@PrimaryColumn({ generated: "increment", type: "int" })
|
||||
id: number;
|
||||
|
||||
@Column({ type: "enum", enum: Salutation, default: Salutation.none })
|
||||
@Column({
|
||||
type: "varchar",
|
||||
length: "255",
|
||||
default: Salutation.none.toString(),
|
||||
transformer: {
|
||||
to(value: Salutation) {
|
||||
return value.toString();
|
||||
},
|
||||
from(value: string) {
|
||||
return Salutation[value as keyof typeof Salutation];
|
||||
},
|
||||
},
|
||||
})
|
||||
salutation: Salutation;
|
||||
|
||||
@Column({ type: "varchar", length: 255 })
|
||||
|
|
|
@ -22,7 +22,7 @@ export const MAIL_SECURE = process.env.MAIL_SECURE ?? "false";
|
|||
export const CLUB_NAME = process.env.CLUB_NAME ?? "";
|
||||
|
||||
export function configCheck() {
|
||||
if (DB_TYPE == "" ?? typeof DB_TYPE != "string") throw new Error("set valid value to DB_TYPE");
|
||||
if (DB_TYPE != "mysql" && DB_TYPE != "sqlite") throw new Error("set valid value to DB_TYPE (mysql|sqlite)");
|
||||
if (DB_HOST == "" ?? typeof DB_HOST != "string") throw new Error("set valid value to DB_HOST");
|
||||
if (DB_NAME == "" ?? typeof DB_NAME != "string") throw new Error("set valid value to DB_NAME");
|
||||
if (DB_USERNAME == "" ?? typeof DB_USERNAME != "string") throw new Error("set valid value to DB_USERNAME");
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
import { MigrationInterface, QueryRunner, Table, TableForeignKey } from "typeorm";
|
||||
import { DB_TYPE } from "../env.defaults";
|
||||
|
||||
export class Initial1724317398939 implements MigrationInterface {
|
||||
name = "Initial1724317398939";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
const variableType_int = DB_TYPE == "mysql" ? "int" : "integer";
|
||||
|
||||
await queryRunner.createTable(
|
||||
new Table({
|
||||
name: "user",
|
||||
columns: [
|
||||
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "mail", type: "varchar", length: "255", isNullable: false },
|
||||
{ name: "username", type: "varchar", length: "255", isNullable: false },
|
||||
{ name: "secret", type: "varchar", length: "255", isNullable: false },
|
||||
|
@ -21,10 +24,10 @@ export class Initial1724317398939 implements MigrationInterface {
|
|||
new Table({
|
||||
name: "refresh",
|
||||
columns: [
|
||||
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "token", type: "varchar", length: "255", isNullable: false },
|
||||
{ name: "expiry", type: "datetime", isNullable: false },
|
||||
{ name: "userId", type: "int", isNullable: false },
|
||||
{ name: "userId", type: variableType_int, isNullable: false },
|
||||
],
|
||||
}),
|
||||
true
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { MigrationInterface, QueryRunner, TableColumn } from "typeorm";
|
||||
import { DB_TYPE } from "../env.defaults";
|
||||
|
||||
export class RefreshPrimaryChange1724573307851 implements MigrationInterface {
|
||||
name = "RefreshPrimaryChange1724573307851";
|
||||
|
@ -9,12 +10,14 @@ export class RefreshPrimaryChange1724573307851 implements MigrationInterface {
|
|||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
const variableType_int = DB_TYPE == "mysql" ? "int" : "integer";
|
||||
|
||||
await queryRunner.dropPrimaryKey("refresh");
|
||||
await queryRunner.addColumn(
|
||||
"refresh",
|
||||
new TableColumn({
|
||||
name: "id",
|
||||
type: "int",
|
||||
type: variableType_int,
|
||||
isPrimary: true,
|
||||
isNullable: false,
|
||||
isGenerated: true,
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import { MigrationInterface, QueryRunner, Table, TableForeignKey } from "typeorm";
|
||||
import { DB_TYPE } from "../env.defaults";
|
||||
|
||||
export class Permissions1724661484664 implements MigrationInterface {
|
||||
name = "Permissions1724661484664";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
const variableType_int = DB_TYPE == "mysql" ? "int" : "integer";
|
||||
|
||||
await queryRunner.createTable(
|
||||
new Table({
|
||||
name: "permission",
|
||||
|
@ -15,7 +18,7 @@ export class Permissions1724661484664 implements MigrationInterface {
|
|||
isPrimary: true,
|
||||
isNullable: false,
|
||||
},
|
||||
{ name: "userId", type: "int", isPrimary: true, isNullable: false },
|
||||
{ name: "userId", type: variableType_int, isPrimary: true, isNullable: false },
|
||||
],
|
||||
}),
|
||||
true
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
import { MigrationInterface, QueryRunner, Table, TableForeignKey, TableIndex } from "typeorm";
|
||||
import { DB_TYPE } from "../env.defaults";
|
||||
|
||||
export class RolePermission1724771491085 implements MigrationInterface {
|
||||
name = "RolePermission1724771491085";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
const variableType_int = DB_TYPE == "mysql" ? "int" : "integer";
|
||||
|
||||
await queryRunner.createTable(
|
||||
new Table({
|
||||
name: "role",
|
||||
columns: [
|
||||
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "role", type: "varchar", length: "255", isNullable: false },
|
||||
],
|
||||
}),
|
||||
|
@ -26,7 +29,7 @@ export class RolePermission1724771491085 implements MigrationInterface {
|
|||
isPrimary: true,
|
||||
isNullable: false,
|
||||
},
|
||||
{ name: "roleId", type: "int", isPrimary: true, isNullable: false },
|
||||
{ name: "roleId", type: variableType_int, isPrimary: true, isNullable: false },
|
||||
],
|
||||
}),
|
||||
true
|
||||
|
@ -38,8 +41,8 @@ export class RolePermission1724771491085 implements MigrationInterface {
|
|||
new Table({
|
||||
name: "user_roles",
|
||||
columns: [
|
||||
{ name: "userId", type: "int", isPrimary: true, isNullable: false },
|
||||
{ name: "roleId", type: "int", isPrimary: true, isNullable: false },
|
||||
{ name: "userId", type: variableType_int, isPrimary: true, isNullable: false },
|
||||
{ name: "roleId", type: variableType_int, isPrimary: true, isNullable: false },
|
||||
],
|
||||
}),
|
||||
true
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
import { MigrationInterface, QueryRunner, Table, TableForeignKey } from "typeorm";
|
||||
import { DB_TYPE } from "../env.defaults";
|
||||
|
||||
export class MemberBaseData1725435669492 implements MigrationInterface {
|
||||
name = "MemberBaseData1725435669492";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
const variableType_int = DB_TYPE == "mysql" ? "int" : "integer";
|
||||
|
||||
await queryRunner.createTable(
|
||||
new Table({
|
||||
name: "award",
|
||||
columns: [
|
||||
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "award", type: "varchar", length: "255", isNullable: false },
|
||||
],
|
||||
}),
|
||||
|
@ -19,7 +22,7 @@ export class MemberBaseData1725435669492 implements MigrationInterface {
|
|||
new Table({
|
||||
name: "communication_type",
|
||||
columns: [
|
||||
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "type", type: "varchar", length: "255", isNullable: false },
|
||||
{ name: "useColumns", type: "varchar", length: "255", isNullable: false, default: "''" },
|
||||
],
|
||||
|
@ -31,15 +34,15 @@ export class MemberBaseData1725435669492 implements MigrationInterface {
|
|||
new Table({
|
||||
name: "communication",
|
||||
columns: [
|
||||
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "preffered", type: "tinyint", isNullable: false, default: 0 },
|
||||
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "preferred", type: "tinyint", isNullable: false, default: 0 },
|
||||
{ name: "mobile", type: "varchar", length: "255", isNullable: false },
|
||||
{ name: "email", type: "varchar", length: "255", isNullable: false },
|
||||
{ name: "city", type: "varchar", length: "255", isNullable: false },
|
||||
{ name: "street", type: "varchar", length: "255", isNullable: false },
|
||||
{ name: "streetNumber", type: "int", isNullable: false },
|
||||
{ name: "streetNumber", type: variableType_int, isNullable: false },
|
||||
{ name: "streetNumberAddition", type: "varchar", length: "255", isNullable: false },
|
||||
{ name: "typeId", type: "int", isNullable: false },
|
||||
{ name: "typeId", type: variableType_int, isNullable: false },
|
||||
],
|
||||
}),
|
||||
true
|
||||
|
@ -49,7 +52,7 @@ export class MemberBaseData1725435669492 implements MigrationInterface {
|
|||
new Table({
|
||||
name: "executive_position",
|
||||
columns: [
|
||||
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "position", type: "varchar", length: "255", isNullable: false },
|
||||
],
|
||||
}),
|
||||
|
@ -60,7 +63,7 @@ export class MemberBaseData1725435669492 implements MigrationInterface {
|
|||
new Table({
|
||||
name: "membership_status",
|
||||
columns: [
|
||||
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "status", type: "varchar", length: "255", isNullable: false },
|
||||
],
|
||||
}),
|
||||
|
@ -71,7 +74,7 @@ export class MemberBaseData1725435669492 implements MigrationInterface {
|
|||
new Table({
|
||||
name: "qualification",
|
||||
columns: [
|
||||
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "qualification", type: "varchar", length: "255", isNullable: false },
|
||||
{ name: "description", type: "varchar", length: "255", isNullable: true },
|
||||
],
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
import { MigrationInterface, QueryRunner, Table, TableColumn, TableForeignKey } from "typeorm";
|
||||
import { DB_TYPE } from "../env.defaults";
|
||||
|
||||
export class Memberdata1726301836849 implements MigrationInterface {
|
||||
name = "Memberdata1726301836849";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
const variableType_int = DB_TYPE == "mysql" ? "int" : "integer";
|
||||
|
||||
await queryRunner.createTable(
|
||||
new Table({
|
||||
name: "membership",
|
||||
columns: [
|
||||
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "internalId", type: "varchar", length: "255", isNullable: true },
|
||||
{ name: "start", type: "date", isNullable: false },
|
||||
{ name: "end", type: "date", isNullable: true },
|
||||
{ name: "terminationReason", type: "varchar", length: "255", isNullable: true },
|
||||
{ name: "memberId", type: "int", isNullable: false },
|
||||
{ name: "statusId", type: "int", isNullable: false },
|
||||
{ name: "memberId", type: variableType_int, isNullable: false },
|
||||
{ name: "statusId", type: variableType_int, isNullable: false },
|
||||
],
|
||||
uniques: [{ name: "IDX_703f499fe3a9892e3a8790cdfc", columnNames: ["internalId"] }],
|
||||
}),
|
||||
|
@ -25,13 +28,13 @@ export class Memberdata1726301836849 implements MigrationInterface {
|
|||
new Table({
|
||||
name: "member_qualifications",
|
||||
columns: [
|
||||
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "note", type: "varchar", length: "255", isNullable: true },
|
||||
{ name: "start", type: "date", isNullable: false },
|
||||
{ name: "end", type: "date", isNullable: true },
|
||||
{ name: "terminationReason", type: "varchar", length: "255", isNullable: true },
|
||||
{ name: "memberId", type: "int", isNullable: false },
|
||||
{ name: "qualificationId", type: "int", isNullable: false },
|
||||
{ name: "memberId", type: variableType_int, isNullable: false },
|
||||
{ name: "qualificationId", type: variableType_int, isNullable: false },
|
||||
],
|
||||
}),
|
||||
true
|
||||
|
@ -41,12 +44,12 @@ export class Memberdata1726301836849 implements MigrationInterface {
|
|||
new Table({
|
||||
name: "member_executive_positions",
|
||||
columns: [
|
||||
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "note", type: "varchar", length: "255", isNullable: true },
|
||||
{ name: "start", type: "date", isNullable: false },
|
||||
{ name: "end", type: "date", isNullable: true },
|
||||
{ name: "memberId", type: "int", isNullable: false },
|
||||
{ name: "executivePositionId", type: "int", isNullable: false },
|
||||
{ name: "memberId", type: variableType_int, isNullable: false },
|
||||
{ name: "executivePositionId", type: variableType_int, isNullable: false },
|
||||
],
|
||||
}),
|
||||
true
|
||||
|
@ -56,19 +59,13 @@ export class Memberdata1726301836849 implements MigrationInterface {
|
|||
new Table({
|
||||
name: "member",
|
||||
columns: [
|
||||
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{
|
||||
name: "salutation",
|
||||
type: "enum",
|
||||
enum: ["sir", "madam", "other", "none"],
|
||||
default: "'none'",
|
||||
isNullable: false,
|
||||
},
|
||||
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "salutation", type: "varchar", length: "255", default: "'none'", isNullable: false },
|
||||
{ name: "firstname", type: "varchar", length: "255", isNullable: false },
|
||||
{ name: "lastname", type: "varchar", length: "255", isNullable: false },
|
||||
{ name: "nameaffix", type: "varchar", length: "255", isNullable: false },
|
||||
{ name: "birthdate", type: "date", isNullable: false },
|
||||
{ name: "sendNewsletterId", type: "int", isNullable: true },
|
||||
{ name: "sendNewsletterId", type: variableType_int, isNullable: true },
|
||||
],
|
||||
uniques: [{ name: "REL_d57e160c4513cd949159217281", columnNames: ["sendNewsletterId"] }],
|
||||
}),
|
||||
|
@ -79,18 +76,21 @@ export class Memberdata1726301836849 implements MigrationInterface {
|
|||
new Table({
|
||||
name: "member_awards",
|
||||
columns: [
|
||||
{ name: "id", type: "int", isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "id", type: variableType_int, isPrimary: true, isGenerated: true, generationStrategy: "increment" },
|
||||
{ name: "given", type: "tinyint", default: 1, isNullable: false },
|
||||
{ name: "note", type: "varchar", length: "255", isNullable: true },
|
||||
{ name: "date", type: "date", isNullable: false },
|
||||
{ name: "memberId", type: "int", isNullable: false },
|
||||
{ name: "awardId", type: "int", isNullable: false },
|
||||
{ name: "memberId", type: variableType_int, isNullable: false },
|
||||
{ name: "awardId", type: variableType_int, isNullable: false },
|
||||
],
|
||||
}),
|
||||
true
|
||||
);
|
||||
|
||||
await queryRunner.addColumn("communication", new TableColumn({ name: "memberId", type: "int", isNullable: false }));
|
||||
await queryRunner.addColumn(
|
||||
"communication",
|
||||
new TableColumn({ name: "memberId", type: variableType_int, isNullable: false })
|
||||
);
|
||||
|
||||
await queryRunner.createForeignKey(
|
||||
"membership",
|
||||
|
|
Loading…
Reference in a new issue