schema change and base operations

This commit is contained in:
Julian Krauser 2025-07-19 11:02:07 +02:00
parent 799a719012
commit 4d37571cb6
27 changed files with 660 additions and 52 deletions

View file

@ -17,7 +17,7 @@ export const damage_report_table = new Table({
{ name: "equipmentId", ...getTypeByORM("uuid", true) },
{ name: "vehicleId", ...getTypeByORM("uuid", true) },
{ name: "wearableId", ...getTypeByORM("uuid", true) },
{ name: "maintenanceId", ...getTypeByORM("uuid", true) },
{ name: "repairId", ...getTypeByORM("uuid", true) },
],
foreignKeys: [
new TableForeignKey({
@ -42,9 +42,9 @@ export const damage_report_table = new Table({
onUpdate: "RESTRICT",
}),
new TableForeignKey({
columnNames: ["maintenanceId"],
columnNames: ["repairId"],
referencedColumnNames: ["id"],
referencedTableName: "maintenance",
referencedTableName: "repair",
onDelete: "SET NULL",
onUpdate: "RESTRICT",
}),
@ -56,8 +56,8 @@ export const maintenance_table = new Table({
columns: [
{ name: "id", ...getTypeByORM("uuid"), ...isUUIDPrimary },
{ name: "createdAt", ...getTypeByORM("datetime"), default: getDefaultByORM("currentTimestamp") },
{ name: "finishedAt", ...getTypeByORM("datetime", true) },
{ name: "status", ...getTypeByORM("varchar") },
{ name: "done", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) },
{ name: "description", ...getTypeByORM("text") },
{ name: "equipmentId", ...getTypeByORM("uuid", true) },
{ name: "vehicleId", ...getTypeByORM("uuid", true) },
@ -87,3 +87,43 @@ export const maintenance_table = new Table({
}),
],
});
export const repair_table = new Table({
name: "repair",
columns: [
{ name: "id", ...getTypeByORM("uuid"), ...isUUIDPrimary },
{ name: "createdAt", ...getTypeByORM("datetime"), default: getDefaultByORM("currentTimestamp") },
{ name: "finishedAt", ...getTypeByORM("datetime", true) },
{ name: "status", ...getTypeByORM("varchar") },
{ name: "responsible", ...getTypeByORM("varchar") },
{ name: "description", ...getTypeByORM("text") },
{ name: "images", ...getTypeByORM("text") },
{ name: "reportDocument", ...getTypeByORM("varchar") },
{ name: "equipmentId", ...getTypeByORM("uuid", true) },
{ name: "vehicleId", ...getTypeByORM("uuid", true) },
{ name: "wearableId", ...getTypeByORM("uuid", true) },
],
foreignKeys: [
new TableForeignKey({
columnNames: ["equipmentId"],
referencedColumnNames: ["id"],
referencedTableName: "equipment",
onDelete: "CASCADE",
onUpdate: "RESTRICT",
}),
new TableForeignKey({
columnNames: ["vehicleId"],
referencedColumnNames: ["id"],
referencedTableName: "vehicle",
onDelete: "CASCADE",
onUpdate: "RESTRICT",
}),
new TableForeignKey({
columnNames: ["wearableId"],
referencedColumnNames: ["id"],
referencedTableName: "wearable",
onDelete: "CASCADE",
onUpdate: "RESTRICT",
}),
],
});