added detail form entities
This commit is contained in:
parent
61011e5e0f
commit
89b28b6e25
12 changed files with 369 additions and 9 deletions
|
@ -16,6 +16,10 @@ import { CreateSchema1739697068682 } from "./migrations/1739697068682-CreateSche
|
||||||
import { vehicle } from "./entity/configuration/vehicle";
|
import { vehicle } from "./entity/configuration/vehicle";
|
||||||
import { equipment } from "./entity/configuration/equipment";
|
import { equipment } from "./entity/configuration/equipment";
|
||||||
import { mission } from "./entity/operation/mission";
|
import { mission } from "./entity/operation/mission";
|
||||||
|
import { mission_force } from "./entity/operation/mission_force";
|
||||||
|
import { mission_equipment } from "./entity/operation/mission_equipment";
|
||||||
|
import { mission_vehicle } from "./entity/operation/mission_vehicle";
|
||||||
|
import { mission_contact } from "./entity/operation/mission_contact";
|
||||||
|
|
||||||
const dataSource = new DataSource({
|
const dataSource = new DataSource({
|
||||||
type: DB_TYPE as any,
|
type: DB_TYPE as any,
|
||||||
|
@ -27,7 +31,23 @@ const dataSource = new DataSource({
|
||||||
synchronize: false,
|
synchronize: false,
|
||||||
logging: process.env.NODE_ENV ? true : ["schema", "error", "warn", "log", "migration"],
|
logging: process.env.NODE_ENV ? true : ["schema", "error", "warn", "log", "migration"],
|
||||||
bigNumberStrings: false,
|
bigNumberStrings: false,
|
||||||
entities: [user, refresh, invite, reset, userPermission, role, rolePermission, force, vehicle, equipment, mission],
|
entities: [
|
||||||
|
user,
|
||||||
|
refresh,
|
||||||
|
invite,
|
||||||
|
reset,
|
||||||
|
userPermission,
|
||||||
|
role,
|
||||||
|
rolePermission,
|
||||||
|
force,
|
||||||
|
vehicle,
|
||||||
|
equipment,
|
||||||
|
mission,
|
||||||
|
mission_force,
|
||||||
|
mission_equipment,
|
||||||
|
mission_vehicle,
|
||||||
|
mission_contact,
|
||||||
|
],
|
||||||
migrations: [CreateSchema1739697068682],
|
migrations: [CreateSchema1739697068682],
|
||||||
migrationsRun: true,
|
migrationsRun: true,
|
||||||
migrationsTransactionMode: "each",
|
migrationsTransactionMode: "each",
|
||||||
|
|
|
@ -19,4 +19,7 @@ export class equipment {
|
||||||
|
|
||||||
@Column({ type: "date", nullable: true, default: null })
|
@Column({ type: "date", nullable: true, default: null })
|
||||||
decommissioned?: Date;
|
decommissioned?: Date;
|
||||||
|
|
||||||
|
@Column({ type: "boolean", default: false })
|
||||||
|
external: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,4 +22,7 @@ export class force {
|
||||||
|
|
||||||
@Column({ type: "date", nullable: true, default: null })
|
@Column({ type: "date", nullable: true, default: null })
|
||||||
decommissioned?: Date;
|
decommissioned?: Date;
|
||||||
|
|
||||||
|
@Column({ type: "boolean", default: false })
|
||||||
|
external: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,4 +19,7 @@ export class vehicle {
|
||||||
|
|
||||||
@Column({ type: "date", nullable: true, default: null })
|
@Column({ type: "date", nullable: true, default: null })
|
||||||
decommissioned?: Date;
|
decommissioned?: Date;
|
||||||
|
|
||||||
|
@Column({ type: "boolean", default: false })
|
||||||
|
external: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,72 @@
|
||||||
import { Column, CreateDateColumn, Entity, PrimaryColumn } from "typeorm";
|
import { Column, CreateDateColumn, Entity, ManyToOne, OneToMany, PrimaryColumn } from "typeorm";
|
||||||
|
import { force } from "../configuration/force";
|
||||||
|
import { mission_force } from "./mission_force";
|
||||||
|
import { mission_vehicle } from "./mission_vehicle";
|
||||||
|
import { mission_equipment } from "./mission_equipment";
|
||||||
|
import { mission_contact } from "./mission_contact";
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class mission {
|
export class mission {
|
||||||
@PrimaryColumn({ generated: "uuid" })
|
@PrimaryColumn({ generated: "uuid" })
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
@Column({ type: "varchar", length: 255 })
|
@Column({ type: "varchar", length: 255, default: "" })
|
||||||
title: string;
|
title: string;
|
||||||
|
|
||||||
@Column({ type: "varchar", length: 255, nullable: true })
|
@Column({ type: "varchar", length: 36, nullable: true })
|
||||||
keyword?: string;
|
commandId?: string | null;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 36, nullable: true })
|
||||||
|
secretaryId?: string | null;
|
||||||
|
|
||||||
|
@Column({ type: "datetime", nullable: true, default: null })
|
||||||
|
mission_start?: Date | null;
|
||||||
|
|
||||||
|
@Column({ type: "datetime", nullable: true, default: null })
|
||||||
|
mission_end?: Date | null;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255, default: "" })
|
||||||
|
keyword: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255, default: "" })
|
||||||
|
location: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255, default: "" })
|
||||||
|
others: string;
|
||||||
|
|
||||||
|
@Column({ type: "int", default: 0 })
|
||||||
|
rescued: number;
|
||||||
|
|
||||||
|
@Column({ type: "int", default: 0 })
|
||||||
|
recovered: number;
|
||||||
|
|
||||||
|
@Column({ type: "text", default: "" })
|
||||||
|
description: string;
|
||||||
|
|
||||||
@CreateDateColumn()
|
@CreateDateColumn()
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
|
|
||||||
|
@ManyToOne(() => force, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
command: force;
|
||||||
|
|
||||||
|
@ManyToOne(() => force, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
secretary: force;
|
||||||
|
|
||||||
|
@OneToMany(() => mission_force, (mf) => mf.mission, { cascade: ["insert"] })
|
||||||
|
forces: mission_force[];
|
||||||
|
|
||||||
|
@OneToMany(() => mission_vehicle, (mv) => mv.mission, { cascade: ["insert"] })
|
||||||
|
vehicles: mission_vehicle[];
|
||||||
|
|
||||||
|
@OneToMany(() => mission_equipment, (me) => me.mission, { cascade: ["insert"] })
|
||||||
|
equipments: mission_equipment[];
|
||||||
|
|
||||||
|
@OneToMany(() => mission_contact, (mc) => mc.mission, { cascade: ["insert"] })
|
||||||
|
contacts: mission_contact[];
|
||||||
}
|
}
|
||||||
|
|
33
src/entity/operation/mission_contact.ts
Normal file
33
src/entity/operation/mission_contact.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm";
|
||||||
|
import { mission } from "./mission";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class mission_contact {
|
||||||
|
@PrimaryColumn({ type: "varchar", length: 36 })
|
||||||
|
missionId: string;
|
||||||
|
|
||||||
|
@PrimaryColumn({ type: "varchar", length: 36 })
|
||||||
|
contactId: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255, default: "" })
|
||||||
|
firstname: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255, default: "" })
|
||||||
|
lastname: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255, default: "" })
|
||||||
|
phone: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255, default: "" })
|
||||||
|
address: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255, default: "" })
|
||||||
|
note: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => mission, {
|
||||||
|
nullable: false,
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
mission: mission;
|
||||||
|
}
|
28
src/entity/operation/mission_equipment.ts
Normal file
28
src/entity/operation/mission_equipment.ts
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm";
|
||||||
|
import { mission } from "./mission";
|
||||||
|
import { equipment } from "../configuration/equipment";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class mission_equipment {
|
||||||
|
@PrimaryColumn({ type: "varchar", length: 36 })
|
||||||
|
missionId: string;
|
||||||
|
|
||||||
|
@PrimaryColumn({ type: "varchar", length: 36 })
|
||||||
|
equipmentId: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 255, default: "" })
|
||||||
|
note: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => mission, {
|
||||||
|
nullable: false,
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
mission: mission;
|
||||||
|
|
||||||
|
@ManyToOne(() => equipment, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
equipment: equipment;
|
||||||
|
}
|
25
src/entity/operation/mission_force.ts
Normal file
25
src/entity/operation/mission_force.ts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import { Entity, ManyToOne, PrimaryColumn } from "typeorm";
|
||||||
|
import { force } from "../configuration/force";
|
||||||
|
import { mission } from "./mission";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class mission_force {
|
||||||
|
@PrimaryColumn({ type: "varchar", length: 36 })
|
||||||
|
missionId: string;
|
||||||
|
|
||||||
|
@PrimaryColumn({ type: "varchar", length: 36 })
|
||||||
|
forceId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => mission, {
|
||||||
|
nullable: false,
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
mission: mission;
|
||||||
|
|
||||||
|
@ManyToOne(() => force, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
force: force;
|
||||||
|
}
|
50
src/entity/operation/mission_vehicle.ts
Normal file
50
src/entity/operation/mission_vehicle.ts
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm";
|
||||||
|
import { force } from "../configuration/force";
|
||||||
|
import { mission } from "./mission";
|
||||||
|
import { vehicle } from "../configuration/vehicle";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class mission_vehicle {
|
||||||
|
@PrimaryColumn({ type: "varchar", length: 36 })
|
||||||
|
missionId: string;
|
||||||
|
|
||||||
|
@PrimaryColumn({ type: "varchar", length: 36 })
|
||||||
|
vehicleId: string;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 36, nullable: true })
|
||||||
|
driverId?: string | null;
|
||||||
|
|
||||||
|
@Column({ type: "varchar", length: 36, nullable: true })
|
||||||
|
leaderId?: string | null;
|
||||||
|
|
||||||
|
@Column({ type: "int", nullable: true, default: null })
|
||||||
|
mileage_start?: number | null;
|
||||||
|
|
||||||
|
@Column({ type: "int", nullable: true, default: null })
|
||||||
|
mileage_end?: number | null;
|
||||||
|
|
||||||
|
@ManyToOne(() => mission, {
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
mission: mission;
|
||||||
|
|
||||||
|
@ManyToOne(() => vehicle, {
|
||||||
|
nullable: false,
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
vehicle: vehicle;
|
||||||
|
|
||||||
|
@ManyToOne(() => force, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
driver: force;
|
||||||
|
|
||||||
|
@ManyToOne(() => force, {
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
})
|
||||||
|
leader: force;
|
||||||
|
}
|
|
@ -10,7 +10,13 @@ import {
|
||||||
user_table,
|
user_table,
|
||||||
} from "./baseSchemaTables/admin";
|
} from "./baseSchemaTables/admin";
|
||||||
import { equipment_table, force_table, vehicle_table } from "./baseSchemaTables/configuration";
|
import { equipment_table, force_table, vehicle_table } from "./baseSchemaTables/configuration";
|
||||||
import { mission_table } from "./baseSchemaTables/operation";
|
import {
|
||||||
|
mission_contact_table,
|
||||||
|
mission_equipment_table,
|
||||||
|
mission_force_table,
|
||||||
|
mission_table,
|
||||||
|
mission_vehicle_table,
|
||||||
|
} from "./baseSchemaTables/operation";
|
||||||
|
|
||||||
export class CreateSchema1739697068682 implements MigrationInterface {
|
export class CreateSchema1739697068682 implements MigrationInterface {
|
||||||
name = "CreateSchema1739697068682";
|
name = "CreateSchema1739697068682";
|
||||||
|
@ -30,9 +36,17 @@ export class CreateSchema1739697068682 implements MigrationInterface {
|
||||||
await queryRunner.createTable(vehicle_table, true, true, true);
|
await queryRunner.createTable(vehicle_table, true, true, true);
|
||||||
|
|
||||||
await queryRunner.createTable(mission_table, true, true, true);
|
await queryRunner.createTable(mission_table, true, true, true);
|
||||||
|
await queryRunner.createTable(mission_force_table, true, true, true);
|
||||||
|
await queryRunner.createTable(mission_vehicle_table, true, true, true);
|
||||||
|
await queryRunner.createTable(mission_equipment_table, true, true, true);
|
||||||
|
await queryRunner.createTable(mission_contact_table, true, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.dropTable("mission_contact", true, true, true);
|
||||||
|
await queryRunner.dropTable("mission_equipment", true, true, true);
|
||||||
|
await queryRunner.dropTable("mission_vehicle", true, true, true);
|
||||||
|
await queryRunner.dropTable("mission_force", true, true, true);
|
||||||
await queryRunner.dropTable("mission", true, true, true);
|
await queryRunner.dropTable("mission", true, true, true);
|
||||||
|
|
||||||
await queryRunner.dropTable("vehicle", true, true, true);
|
await queryRunner.dropTable("vehicle", true, true, true);
|
||||||
|
|
|
@ -11,6 +11,7 @@ export const force_table = new Table({
|
||||||
{ name: "nameaffix", ...getTypeByORM("varchar") },
|
{ name: "nameaffix", ...getTypeByORM("varchar") },
|
||||||
{ name: "commissioned", ...getTypeByORM("date"), default: getDefaultByORM("currentDate") },
|
{ name: "commissioned", ...getTypeByORM("date"), default: getDefaultByORM("currentDate") },
|
||||||
{ name: "decommissioned", ...getTypeByORM("date", true), default: getDefaultByORM("null") },
|
{ name: "decommissioned", ...getTypeByORM("date", true), default: getDefaultByORM("null") },
|
||||||
|
{ name: "external", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -23,6 +24,7 @@ export const equipment_table = new Table({
|
||||||
{ name: "name", ...getTypeByORM("varchar"), isUnique: true },
|
{ name: "name", ...getTypeByORM("varchar"), isUnique: true },
|
||||||
{ name: "commissioned", ...getTypeByORM("date"), default: getDefaultByORM("currentDate") },
|
{ name: "commissioned", ...getTypeByORM("date"), default: getDefaultByORM("currentDate") },
|
||||||
{ name: "decommissioned", ...getTypeByORM("date", true), default: getDefaultByORM("null") },
|
{ name: "decommissioned", ...getTypeByORM("date", true), default: getDefaultByORM("null") },
|
||||||
|
{ name: "external", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -35,5 +37,6 @@ export const vehicle_table = new Table({
|
||||||
{ name: "name", ...getTypeByORM("varchar"), isUnique: true },
|
{ name: "name", ...getTypeByORM("varchar"), isUnique: true },
|
||||||
{ name: "commissioned", ...getTypeByORM("date"), default: getDefaultByORM("currentDate") },
|
{ name: "commissioned", ...getTypeByORM("date"), default: getDefaultByORM("currentDate") },
|
||||||
{ name: "decommissioned", ...getTypeByORM("date", true), default: getDefaultByORM("null") },
|
{ name: "decommissioned", ...getTypeByORM("date", true), default: getDefaultByORM("null") },
|
||||||
|
{ name: "external", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,134 @@
|
||||||
import { Table } from "typeorm";
|
import { Table, TableForeignKey } from "typeorm";
|
||||||
import { getDefaultByORM, getTypeByORM, isUUIDPrimary } from "../ormHelper";
|
import { getDefaultByORM, getTypeByORM, isUUIDPrimary } from "../ormHelper";
|
||||||
|
|
||||||
export const mission_table = new Table({
|
export const mission_table = new Table({
|
||||||
name: "mission",
|
name: "mission",
|
||||||
columns: [
|
columns: [
|
||||||
{ name: "id", ...getTypeByORM("uuid"), ...isUUIDPrimary },
|
{ name: "id", ...getTypeByORM("uuid"), ...isUUIDPrimary },
|
||||||
{ name: "title", ...getTypeByORM("varchar") },
|
{ name: "title", ...getTypeByORM("varchar"), default: getDefaultByORM("string") },
|
||||||
{ name: "keyword", ...getTypeByORM("varchar", true), default: getDefaultByORM("null") },
|
{ name: "commandId", ...getTypeByORM("uuid", true), default: getDefaultByORM("null") },
|
||||||
|
{ name: "secretaryId", ...getTypeByORM("uuid", true), default: getDefaultByORM("null") },
|
||||||
|
{ name: "mission_start", ...getTypeByORM("datetime", true, 6), default: getDefaultByORM("null") },
|
||||||
|
{ name: "mission_end", ...getTypeByORM("datetime", true, 6), default: getDefaultByORM("null") },
|
||||||
|
{ name: "keyword", ...getTypeByORM("varchar"), default: getDefaultByORM("string") },
|
||||||
|
{ name: "location", ...getTypeByORM("varchar"), default: getDefaultByORM("string") },
|
||||||
|
{ name: "others", ...getTypeByORM("varchar"), default: getDefaultByORM("string") },
|
||||||
|
{ name: "rescued", ...getTypeByORM("int"), default: getDefaultByORM("number", 0) },
|
||||||
|
{ name: "recovered", ...getTypeByORM("int"), default: getDefaultByORM("number", 0) },
|
||||||
|
{ name: "description", ...getTypeByORM("text"), default: getDefaultByORM("string") },
|
||||||
{ name: "createdAt", ...getTypeByORM("datetime", false, 6), default: getDefaultByORM("currentTimestamp") },
|
{ name: "createdAt", ...getTypeByORM("datetime", false, 6), default: getDefaultByORM("currentTimestamp") },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const mission_force_table = new Table({
|
||||||
|
name: "mission_force",
|
||||||
|
columns: [
|
||||||
|
{ name: "missionId", ...getTypeByORM("uuid"), isPrimary: true },
|
||||||
|
{ name: "forceId", ...getTypeByORM("uuid"), isPrimary: true },
|
||||||
|
],
|
||||||
|
foreignKeys: [
|
||||||
|
new TableForeignKey({
|
||||||
|
columnNames: ["missionId"],
|
||||||
|
referencedColumnNames: ["id"],
|
||||||
|
referencedTableName: "mission",
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
}),
|
||||||
|
new TableForeignKey({
|
||||||
|
columnNames: ["forceId"],
|
||||||
|
referencedColumnNames: ["id"],
|
||||||
|
referencedTableName: "force",
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const mission_vehicle_table = new Table({
|
||||||
|
name: "mission_vehicle",
|
||||||
|
columns: [
|
||||||
|
{ name: "missionId", ...getTypeByORM("uuid"), isPrimary: true },
|
||||||
|
{ name: "vehicleId", ...getTypeByORM("uuid"), isPrimary: true },
|
||||||
|
{ name: "driverId", ...getTypeByORM("uuid", true), default: getDefaultByORM("null") },
|
||||||
|
{ name: "leaderId", ...getTypeByORM("uuid", true), default: getDefaultByORM("null") },
|
||||||
|
{ name: "mileage_start", ...getTypeByORM("int", true), default: getDefaultByORM("null") },
|
||||||
|
{ name: "mileage_end", ...getTypeByORM("int", true), default: getDefaultByORM("null") },
|
||||||
|
],
|
||||||
|
foreignKeys: [
|
||||||
|
new TableForeignKey({
|
||||||
|
columnNames: ["missionId"],
|
||||||
|
referencedColumnNames: ["id"],
|
||||||
|
referencedTableName: "mission",
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
}),
|
||||||
|
new TableForeignKey({
|
||||||
|
columnNames: ["vehicleId"],
|
||||||
|
referencedColumnNames: ["id"],
|
||||||
|
referencedTableName: "vehicle",
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
}),
|
||||||
|
new TableForeignKey({
|
||||||
|
columnNames: ["driverId"],
|
||||||
|
referencedColumnNames: ["id"],
|
||||||
|
referencedTableName: "force",
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
}),
|
||||||
|
new TableForeignKey({
|
||||||
|
columnNames: ["leaderId"],
|
||||||
|
referencedColumnNames: ["id"],
|
||||||
|
referencedTableName: "force",
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const mission_equipment_table = new Table({
|
||||||
|
name: "mission_equipment",
|
||||||
|
columns: [
|
||||||
|
{ name: "missionId", ...getTypeByORM("uuid"), isPrimary: true },
|
||||||
|
{ name: "equipmentId", ...getTypeByORM("uuid"), isPrimary: true },
|
||||||
|
{ name: "note", ...getTypeByORM("varchar"), default: getDefaultByORM("string") },
|
||||||
|
],
|
||||||
|
foreignKeys: [
|
||||||
|
new TableForeignKey({
|
||||||
|
columnNames: ["missionId"],
|
||||||
|
referencedColumnNames: ["id"],
|
||||||
|
referencedTableName: "mission",
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
}),
|
||||||
|
new TableForeignKey({
|
||||||
|
columnNames: ["equipmentId"],
|
||||||
|
referencedColumnNames: ["id"],
|
||||||
|
referencedTableName: "equipment",
|
||||||
|
onDelete: "RESTRICT",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const mission_contact_table = new Table({
|
||||||
|
name: "mission_contact",
|
||||||
|
columns: [
|
||||||
|
{ name: "missionId", ...getTypeByORM("uuid"), isPrimary: true },
|
||||||
|
{ name: "contactId", ...getTypeByORM("uuid"), isPrimary: true },
|
||||||
|
{ name: "firstname", ...getTypeByORM("varchar"), default: getDefaultByORM("string") },
|
||||||
|
{ name: "lastname", ...getTypeByORM("varchar"), default: getDefaultByORM("string") },
|
||||||
|
{ name: "phone", ...getTypeByORM("varchar"), default: getDefaultByORM("string") },
|
||||||
|
{ name: "address", ...getTypeByORM("varchar"), default: getDefaultByORM("string") },
|
||||||
|
{ name: "note", ...getTypeByORM("varchar"), default: getDefaultByORM("string") },
|
||||||
|
],
|
||||||
|
foreignKeys: [
|
||||||
|
new TableForeignKey({
|
||||||
|
columnNames: ["missionId"],
|
||||||
|
referencedColumnNames: ["id"],
|
||||||
|
referencedTableName: "mission",
|
||||||
|
onDelete: "CASCADE",
|
||||||
|
onUpdate: "RESTRICT",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue