| @@ -10,7 +10,7 @@ import Vapor | |||||
| struct cntrlReason: RouteCollection { | struct cntrlReason: RouteCollection { | ||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("resons") | |||||
| let rts = routes.grouped("reasons") | |||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | rts.put(use: update) | ||||
| @@ -10,7 +10,7 @@ import Vapor | |||||
| struct cntrlCompartmentLocation: RouteCollection { | struct cntrlCompartmentLocation: RouteCollection { | ||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("comparmentlocations") | |||||
| let rts = routes.grouped("compartmentlocations") | |||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | rts.put(use: update) | ||||
| @@ -10,7 +10,7 @@ import Vapor | |||||
| struct cntrlObjProperty: RouteCollection { | struct cntrlObjProperty: RouteCollection { | ||||
| func boot(routes: RoutesBuilder) throws { | func boot(routes: RoutesBuilder) throws { | ||||
| let rts = routes.grouped("objproperies") | |||||
| let rts = routes.grouped("objproperties") | |||||
| rts.get(use: index) | rts.get(use: index) | ||||
| rts.post(use: create) | rts.post(use: create) | ||||
| rts.put(use: update) | rts.put(use: update) | ||||
| @@ -1,8 +1,49 @@ | |||||
| // | // | ||||
| // File 2.swift | |||||
| // | |||||
| // cntrlItem.swift | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/3/24. | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/1/24. | |||||
| // | |||||
| import Fluent | |||||
| import Vapor | |||||
| import Foundation | |||||
| struct cntrlItem: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | |||||
| let rts = routes.grouped("items") | |||||
| rts.get(use: index) | |||||
| rts.post(use: create) | |||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.delete(use: delete) | |||||
| } | |||||
| } | |||||
| func index(req: Request) async throws -> [mdlItem] { | |||||
| try await mdlItem.query(on: req.db).all() | |||||
| } | |||||
| func create(req: Request) async throws -> mdlItem { | |||||
| let obj = try req.content.decode(mdlItem.self) | |||||
| try await obj.save(on: req.db) | |||||
| return obj | |||||
| } | |||||
| func update(req: Request) async throws -> mdlItem{ | |||||
| let obj = try req.content.decode(mdlItem.self) | |||||
| let dbobj = try await mdlItem.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | |||||
| guard let obj = try await mdlItem.find(req.parameters.get("id"), on: req.db) else { | |||||
| throw Abort(.notFound) | |||||
| } | |||||
| try await obj.delete(on: req.db) | |||||
| return .noContent | |||||
| } | |||||
| } | |||||
| @@ -1,8 +1,49 @@ | |||||
| // | // | ||||
| // File.swift | |||||
| // | |||||
| // cntrlItemResponseType.swift | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/3/24. | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/1/24. | |||||
| // | |||||
| import Fluent | |||||
| import Vapor | |||||
| import Foundation | |||||
| struct cntrlItemResponseType: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | |||||
| let rts = routes.grouped("itemresponsetypes") | |||||
| rts.get(use: index) | |||||
| rts.post(use: create) | |||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.delete(use: delete) | |||||
| } | |||||
| } | |||||
| func index(req: Request) async throws -> [mdlItemResponseType] { | |||||
| try await mdlItemResponseType.query(on: req.db).all() | |||||
| } | |||||
| func create(req: Request) async throws -> mdlItemResponseType { | |||||
| let obj = try req.content.decode(mdlItemResponseType.self) | |||||
| try await obj.save(on: req.db) | |||||
| return obj | |||||
| } | |||||
| func update(req: Request) async throws -> mdlItemResponseType{ | |||||
| let obj = try req.content.decode(mdlItemResponseType.self) | |||||
| let dbobj = try await mdlItemResponseType.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | |||||
| guard let obj = try await mdlItemResponseType.find(req.parameters.get("id"), on: req.db) else { | |||||
| throw Abort(.notFound) | |||||
| } | |||||
| try await obj.delete(on: req.db) | |||||
| return .noContent | |||||
| } | |||||
| } | |||||
| @@ -1,8 +1,49 @@ | |||||
| // | // | ||||
| // File.swift | |||||
| // | |||||
| // cntrlLabSetting.swift | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/3/24. | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/1/24. | |||||
| // | |||||
| import Fluent | |||||
| import Vapor | |||||
| import Foundation | |||||
| struct cntrlLabSetting: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | |||||
| let rts = routes.grouped("labsettings") | |||||
| rts.get(use: index) | |||||
| rts.post(use: create) | |||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.delete(use: delete) | |||||
| } | |||||
| } | |||||
| func index(req: Request) async throws -> [mdlLabSetting] { | |||||
| try await mdlLabSetting.query(on: req.db).all() | |||||
| } | |||||
| func create(req: Request) async throws -> mdlLabSetting { | |||||
| let obj = try req.content.decode(mdlLabSetting.self) | |||||
| try await obj.save(on: req.db) | |||||
| return obj | |||||
| } | |||||
| func update(req: Request) async throws -> mdlLabSetting{ | |||||
| let obj = try req.content.decode(mdlLabSetting.self) | |||||
| let dbobj = try await mdlLabSetting.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | |||||
| guard let obj = try await mdlLabSetting.find(req.parameters.get("id"), on: req.db) else { | |||||
| throw Abort(.notFound) | |||||
| } | |||||
| try await obj.delete(on: req.db) | |||||
| return .noContent | |||||
| } | |||||
| } | |||||
| @@ -1,8 +1,49 @@ | |||||
| // | // | ||||
| // File 2.swift | |||||
| // | |||||
| // cntrlXFluidViscosity.swift | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/3/24. | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/1/24. | |||||
| // | |||||
| import Fluent | |||||
| import Vapor | |||||
| import Foundation | |||||
| struct cntrlXFluidViscosity: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | |||||
| let rts = routes.grouped("xfluidviscosities") | |||||
| rts.get(use: index) | |||||
| rts.post(use: create) | |||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.delete(use: delete) | |||||
| } | |||||
| } | |||||
| func index(req: Request) async throws -> [mdlXFluidViscosity] { | |||||
| try await mdlXFluidViscosity.query(on: req.db).all() | |||||
| } | |||||
| func create(req: Request) async throws -> mdlXFluidViscosity { | |||||
| let obj = try req.content.decode(mdlXFluidViscosity.self) | |||||
| try await obj.save(on: req.db) | |||||
| return obj | |||||
| } | |||||
| func update(req: Request) async throws -> mdlXFluidViscosity{ | |||||
| let obj = try req.content.decode(mdlXFluidViscosity.self) | |||||
| let dbobj = try await mdlXFluidViscosity.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | |||||
| guard let obj = try await mdlXFluidViscosity.find(req.parameters.get("id"), on: req.db) else { | |||||
| throw Abort(.notFound) | |||||
| } | |||||
| try await obj.delete(on: req.db) | |||||
| return .noContent | |||||
| } | |||||
| } | |||||
| @@ -1,8 +1,49 @@ | |||||
| // | // | ||||
| // File 3.swift | |||||
| // | |||||
| // cntrlXUserRole.swift | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/3/24. | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/1/24. | |||||
| // | |||||
| import Fluent | |||||
| import Vapor | |||||
| import Foundation | |||||
| struct cntrlXUserRole: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | |||||
| let rts = routes.grouped("xuserroles") | |||||
| rts.get(use: index) | |||||
| rts.post(use: create) | |||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.delete(use: delete) | |||||
| } | |||||
| } | |||||
| func index(req: Request) async throws -> [mdlXUserRole] { | |||||
| try await mdlXUserRole.query(on: req.db).all() | |||||
| } | |||||
| func create(req: Request) async throws -> mdlXUserRole { | |||||
| let obj = try req.content.decode(mdlXUserRole.self) | |||||
| try await obj.save(on: req.db) | |||||
| return obj | |||||
| } | |||||
| func update(req: Request) async throws -> mdlXUserRole{ | |||||
| let obj = try req.content.decode(mdlXUserRole.self) | |||||
| let dbobj = try await mdlXUserRole.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | |||||
| guard let obj = try await mdlXUserRole.find(req.parameters.get("id"), on: req.db) else { | |||||
| throw Abort(.notFound) | |||||
| } | |||||
| try await obj.delete(on: req.db) | |||||
| return .noContent | |||||
| } | |||||
| } | |||||
| @@ -1,8 +1,49 @@ | |||||
| // | // | ||||
| // File.swift | |||||
| // | |||||
| // cntrlXWorkOrderSegment.swift | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/3/24. | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/1/24. | |||||
| // | |||||
| import Fluent | |||||
| import Vapor | |||||
| import Foundation | |||||
| struct cntrlXWorkOrderSegment: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | |||||
| let rts = routes.grouped("xworkordersegments") | |||||
| rts.get(use: index) | |||||
| rts.post(use: create) | |||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.delete(use: delete) | |||||
| } | |||||
| } | |||||
| func index(req: Request) async throws -> [mdlXWorkOrderSegment] { | |||||
| try await mdlXWorkOrderSegment.query(on: req.db).all() | |||||
| } | |||||
| func create(req: Request) async throws -> mdlXWorkOrderSegment { | |||||
| let obj = try req.content.decode(mdlXWorkOrderSegment.self) | |||||
| try await obj.save(on: req.db) | |||||
| return obj | |||||
| } | |||||
| func update(req: Request) async throws -> mdlXWorkOrderSegment{ | |||||
| let obj = try req.content.decode(mdlXWorkOrderSegment.self) | |||||
| let dbobj = try await mdlXWorkOrderSegment.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | |||||
| guard let obj = try await mdlXWorkOrderSegment.find(req.parameters.get("id"), on: req.db) else { | |||||
| throw Abort(.notFound) | |||||
| } | |||||
| try await obj.delete(on: req.db) | |||||
| return .noContent | |||||
| } | |||||
| } | |||||
| @@ -1,8 +1,49 @@ | |||||
| // | // | ||||
| // File.swift | |||||
| // | |||||
| // cntrlOilSample.swift | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/3/24. | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/1/24. | |||||
| // | |||||
| import Fluent | |||||
| import Vapor | |||||
| import Foundation | |||||
| struct cntrlOilSample: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | |||||
| let rts = routes.grouped("oilsamples") | |||||
| rts.get(use: index) | |||||
| rts.post(use: create) | |||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.delete(use: delete) | |||||
| } | |||||
| } | |||||
| func index(req: Request) async throws -> [mdlOilSample] { | |||||
| try await mdlOilSample.query(on: req.db).all() | |||||
| } | |||||
| func create(req: Request) async throws -> mdlOilSample { | |||||
| let obj = try req.content.decode(mdlOilSample.self) | |||||
| try await obj.save(on: req.db) | |||||
| return obj | |||||
| } | |||||
| func update(req: Request) async throws -> mdlOilSample{ | |||||
| let obj = try req.content.decode(mdlOilSample.self) | |||||
| let dbobj = try await mdlOilSample.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | |||||
| guard let obj = try await mdlOilSample.find(req.parameters.get("id"), on: req.db) else { | |||||
| throw Abort(.notFound) | |||||
| } | |||||
| try await obj.delete(on: req.db) | |||||
| return .noContent | |||||
| } | |||||
| } | |||||
| @@ -1,8 +1,49 @@ | |||||
| // | // | ||||
| // File 2.swift | |||||
| // | |||||
| // cntrlSpec.swift | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/3/24. | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/1/24. | |||||
| // | |||||
| import Fluent | |||||
| import Vapor | |||||
| import Foundation | |||||
| struct cntrlSpec: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | |||||
| let rts = routes.grouped("specs") | |||||
| rts.get(use: index) | |||||
| rts.post(use: create) | |||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.delete(use: delete) | |||||
| } | |||||
| } | |||||
| func index(req: Request) async throws -> [mdlSpec] { | |||||
| try await mdlSpec.query(on: req.db).all() | |||||
| } | |||||
| func create(req: Request) async throws -> mdlSpec { | |||||
| let obj = try req.content.decode(mdlSpec.self) | |||||
| try await obj.save(on: req.db) | |||||
| return obj | |||||
| } | |||||
| func update(req: Request) async throws -> mdlSpec{ | |||||
| let obj = try req.content.decode(mdlSpec.self) | |||||
| let dbobj = try await mdlSpec.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | |||||
| guard let obj = try await mdlSpec.find(req.parameters.get("id"), on: req.db) else { | |||||
| throw Abort(.notFound) | |||||
| } | |||||
| try await obj.delete(on: req.db) | |||||
| return .noContent | |||||
| } | |||||
| } | |||||
| @@ -1,8 +1,49 @@ | |||||
| // | // | ||||
| // File 3.swift | |||||
| // | |||||
| // cntrlSpecItem.swift | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/3/24. | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/1/24. | |||||
| // | |||||
| import Fluent | |||||
| import Vapor | |||||
| import Foundation | |||||
| struct cntrlSpecItem: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | |||||
| let rts = routes.grouped("specitems") | |||||
| rts.get(use: index) | |||||
| rts.post(use: create) | |||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.delete(use: delete) | |||||
| } | |||||
| } | |||||
| func index(req: Request) async throws -> [mdlSpecItem] { | |||||
| try await mdlSpecItem.query(on: req.db).all() | |||||
| } | |||||
| func create(req: Request) async throws -> mdlSpecItem { | |||||
| let obj = try req.content.decode(mdlSpecItem.self) | |||||
| try await obj.save(on: req.db) | |||||
| return obj | |||||
| } | |||||
| func update(req: Request) async throws -> mdlSpecItem{ | |||||
| let obj = try req.content.decode(mdlSpecItem.self) | |||||
| let dbobj = try await mdlSpecItem.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | |||||
| guard let obj = try await mdlSpecItem.find(req.parameters.get("id"), on: req.db) else { | |||||
| throw Abort(.notFound) | |||||
| } | |||||
| try await obj.delete(on: req.db) | |||||
| return .noContent | |||||
| } | |||||
| } | |||||
| @@ -1,8 +1,49 @@ | |||||
| // | // | ||||
| // File.swift | |||||
| // | |||||
| // cntrlSpecItemValue.swift | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/3/24. | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/1/24. | |||||
| // | |||||
| import Fluent | |||||
| import Vapor | |||||
| import Foundation | |||||
| struct cntrlSpecItemValue: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | |||||
| let rts = routes.grouped("specitemvalues") | |||||
| rts.get(use: index) | |||||
| rts.post(use: create) | |||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.delete(use: delete) | |||||
| } | |||||
| } | |||||
| func index(req: Request) async throws -> [mdlSpecItemValue] { | |||||
| try await mdlSpecItemValue.query(on: req.db).all() | |||||
| } | |||||
| func create(req: Request) async throws -> mdlSpecItemValue { | |||||
| let obj = try req.content.decode(mdlSpecItemValue.self) | |||||
| try await obj.save(on: req.db) | |||||
| return obj | |||||
| } | |||||
| func update(req: Request) async throws -> mdlSpecItemValue{ | |||||
| let obj = try req.content.decode(mdlSpecItemValue.self) | |||||
| let dbobj = try await mdlSpecItemValue.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | |||||
| guard let obj = try await mdlSpecItemValue.find(req.parameters.get("id"), on: req.db) else { | |||||
| throw Abort(.notFound) | |||||
| } | |||||
| try await obj.delete(on: req.db) | |||||
| return .noContent | |||||
| } | |||||
| } | |||||
| @@ -1,8 +1,49 @@ | |||||
| // | // | ||||
| // File.swift | |||||
| // | |||||
| // cntrlWorkOrder.swift | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/3/24. | |||||
| // | // | ||||
| // Created by Michiel Carman on 4/1/24. | |||||
| // | |||||
| import Fluent | |||||
| import Vapor | |||||
| import Foundation | |||||
| struct cntrlWorkOrder: RouteCollection { | |||||
| func boot(routes: RoutesBuilder) throws { | |||||
| let rts = routes.grouped("workorders") | |||||
| rts.get(use: index) | |||||
| rts.post(use: create) | |||||
| rts.put(use: update) | |||||
| rts.group(":id") { rt in | |||||
| rts.delete(use: delete) | |||||
| } | |||||
| } | |||||
| func index(req: Request) async throws -> [mdlWorkOrder] { | |||||
| try await mdlWorkOrder.query(on: req.db).all() | |||||
| } | |||||
| func create(req: Request) async throws -> mdlWorkOrder { | |||||
| let obj = try req.content.decode(mdlWorkOrder.self) | |||||
| try await obj.save(on: req.db) | |||||
| return obj | |||||
| } | |||||
| func update(req: Request) async throws -> mdlWorkOrder{ | |||||
| let obj = try req.content.decode(mdlWorkOrder.self) | |||||
| let dbobj = try await mdlWorkOrder.query(on: req.db).filter(\.$id == obj.id!).first()! | |||||
| dbobj.updatedate = Date() | |||||
| dbobj.updateuserid = -1 | |||||
| try await dbobj.update(on: req.db) | |||||
| return dbobj | |||||
| } | |||||
| func delete(req: Request) async throws -> HTTPStatus { | |||||
| guard let obj = try await mdlWorkOrder.find(req.parameters.get("id"), on: req.db) else { | |||||
| throw Abort(.notFound) | |||||
| } | |||||
| try await obj.delete(on: req.db) | |||||
| return .noContent | |||||
| } | |||||
| } | |||||
| @@ -61,6 +61,21 @@ extension mdlResponseType{ | |||||
| try await database.schema("responseType").delete() | try await database.schema("responseType").delete() | ||||
| } | } | ||||
| } | } | ||||
| struct Mod1: AsyncMigration{ | |||||
| func prepare(on database: Database) async throws { | |||||
| try await database.schema("responseType") | |||||
| .field("repairTypeId", .int, .references("repairType", "id")) | |||||
| .deleteField("responseTypeId") | |||||
| .update() | |||||
| } | |||||
| func revert(on database: Database) async throws { | |||||
| try await database.schema("responseType") | |||||
| .field("responseTypeId", .int) | |||||
| .deleteField("repairTypeId") | |||||
| .update() | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -74,6 +74,19 @@ extension mdlContact{ | |||||
| .update() | .update() | ||||
| } | } | ||||
| } | } | ||||
| struct Mod1: AsyncMigration{ | |||||
| func prepare(on database: Database) async throws { | |||||
| try await database.schema("contact") | |||||
| .field("description", .string) | |||||
| .update() | |||||
| } | |||||
| func revert(on database: Database) async throws { | |||||
| try await database.schema("contact") | |||||
| .deleteField("description" ) | |||||
| .update() | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -14,8 +14,8 @@ final class mdlXFluidViscosity: Model, Content { | |||||
| static let schema = "xFluidViscosity" | static let schema = "xFluidViscosity" | ||||
| @ID(custom: "id", generatedBy: .database) var id: Int? | @ID(custom: "id", generatedBy: .database) var id: Int? | ||||
| @Parent(key: "userId") var user: mdlUser | |||||
| @Parent(key: "roleId") var role: mdlRole | |||||
| @Parent(key: "fluidId") var fluid: mdlFluid | |||||
| @Parent(key: "viscosityId") var viscosity: mdlViscosity | |||||
| @Field(key: "sortOrder") var sortorder: Int? | @Field(key: "sortOrder") var sortorder: Int? | ||||
| @@ -28,10 +28,10 @@ final class mdlXFluidViscosity: Model, Content { | |||||
| init(){} | init(){} | ||||
| init(id: Int? = nil, userid: Int, roleid: Int, sortorder: Int? = nil, createdate: Date? = nil, createuserid: Int? = nil, updatedate: Date? = nil, updateuserid: Int? = nil) { | |||||
| init(id: Int? = nil, fluidid: Int, viscosityid: Int, sortorder: Int? = nil, createdate: Date? = nil, createuserid: Int? = nil, updatedate: Date? = nil, updateuserid: Int? = nil) { | |||||
| self.id = id | self.id = id | ||||
| self.user.$id.value = userid | |||||
| self.role.$id.value = roleid | |||||
| self.fluid.$id.value = fluidid | |||||
| self.viscosity.$id.value = viscosityid | |||||
| self.sortorder = sortorder | self.sortorder = sortorder | ||||
| self.createdate = createdate | self.createdate = createdate | ||||
| self.createuserid = createuserid | self.createuserid = createuserid | ||||
| @@ -59,6 +59,25 @@ extension mdlXFluidViscosity{ | |||||
| try await database.schema("user").delete() | try await database.schema("user").delete() | ||||
| } | } | ||||
| } | } | ||||
| struct Mod1: AsyncMigration { | |||||
| func prepare(on database: Database) async throws { | |||||
| try await database.schema("xFluidViscosity") | |||||
| .deleteField("roleid") | |||||
| .deleteField("userId") | |||||
| .field("fluidId", .int, .references("fluid", "id")) | |||||
| .field("viscosityId", .int, .references("viscosity", "id")) | |||||
| .update() | |||||
| } | |||||
| func revert(on database: Database) async throws { | |||||
| try await database.schema("user") | |||||
| .deleteField("fluidId") | |||||
| .deleteField("viscosityId") | |||||
| .field("roleid", .int, .references("role", "id")) | |||||
| .field("userId", .int, .references("user", "id")) | |||||
| .update() | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -95,7 +95,6 @@ extension mdlOilSample{ | |||||
| .field("filterChanged", .bool) | .field("filterChanged", .bool) | ||||
| .field("level", .string) | .field("level", .string) | ||||
| .field("comment", .string) | .field("comment", .string) | ||||
| .field("createDate", .datetime) | .field("createDate", .datetime) | ||||
| .field("createUserId", .int) | .field("createUserId", .int) | ||||
| .field("updateDate", .datetime) | .field("updateDate", .datetime) | ||||
| @@ -107,4 +106,18 @@ extension mdlOilSample{ | |||||
| try await database.schema("oilSample").delete() | try await database.schema("oilSample").delete() | ||||
| } | } | ||||
| } | } | ||||
| struct Mod1: AsyncMigration{ | |||||
| func prepare(on database: Database) async throws { | |||||
| try await database.schema("oilSample") | |||||
| .field("sortOrder", .int) | |||||
| .update() | |||||
| } | |||||
| func revert(on database: Database) async throws { | |||||
| try await database.schema("oilSample") | |||||
| .deleteField("sortOrder") | |||||
| .update() | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -62,6 +62,34 @@ extension mdlSpecItemValue{ | |||||
| try await database.schema("specItemValue").delete() | try await database.schema("specItemValue").delete() | ||||
| } | } | ||||
| } | } | ||||
| struct Mod1: AsyncMigration{ | |||||
| func revert(on database: FluentKit.Database) async throws { | |||||
| try await database.schema("specItemValue") | |||||
| .deleteField("specItemId") | |||||
| .field("itemId", .int, .references("specItem", "id")) | |||||
| .update() | |||||
| } | |||||
| func prepare(on database: FluentKit.Database) async throws { | |||||
| try await database.schema("specItemValue") | |||||
| .deleteField("itemId") | |||||
| .field("specItemId", .int, .references("specItem", "id")) | |||||
| .update() | |||||
| } | |||||
| } | |||||
| struct Mod2: AsyncMigration{ | |||||
| func revert(on database: FluentKit.Database) async throws { | |||||
| try await database.schema("specItemValue") | |||||
| .deleteField("valueTypeId") | |||||
| .update() | |||||
| } | |||||
| func prepare(on database: FluentKit.Database) async throws { | |||||
| try await database.schema("specItemValue") | |||||
| .field("valueTypeId", .int, .references("valueType", "id")) | |||||
| .update() | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -98,6 +98,12 @@ public func configure(_ app: Application) async throws { | |||||
| app.migrations.add(mdlOilSample.Create()) | app.migrations.add(mdlOilSample.Create()) | ||||
| app.migrations.add(mdlXWorkOrderSegment.Create()) | app.migrations.add(mdlXWorkOrderSegment.Create()) | ||||
| app.migrations.add(mdlXUserRole.FixRoleId()) | app.migrations.add(mdlXUserRole.FixRoleId()) | ||||
| app.migrations.add(mdlSpecItemValue.Mod1()) | |||||
| app.migrations.add(mdlSpecItemValue.Mod2()) | |||||
| app.migrations.add(mdlOilSample.Mod1()) | |||||
| app.migrations.add(mdlXFluidViscosity.Mod1()) | |||||
| app.migrations.add(mdlContact.Mod1()) | |||||
| app.migrations.add(mdlResponseType.Mod1()) | |||||
| app.logger.logLevel = .debug | app.logger.logLevel = .debug | ||||
| @@ -35,27 +35,38 @@ func routes(_ app: Application) throws { | |||||
| try baseApp.register(collection: cntrlInputType()) | try baseApp.register(collection: cntrlInputType()) | ||||
| try baseApp.register(collection: cntrlJobSite()) | try baseApp.register(collection: cntrlJobSite()) | ||||
| try baseApp.register(collection: cntrlLevel()) | try baseApp.register(collection: cntrlLevel()) | ||||
| try baseApp.register(collection: cntrlLocation()) | |||||
| try baseApp.register(collection: cntrlNoteType()) | try baseApp.register(collection: cntrlNoteType()) | ||||
| try baseApp.register(collection: cntrlPart()) | try baseApp.register(collection: cntrlPart()) | ||||
| try baseApp.register(collection: cntrlPriority()) | try baseApp.register(collection: cntrlPriority()) | ||||
| try baseApp.register(collection: cntrlReason()) | try baseApp.register(collection: cntrlReason()) | ||||
| try baseApp.register(collection: cntrlRepairType()) | try baseApp.register(collection: cntrlRepairType()) | ||||
| try baseApp.register(collection: cntrlSignatureType()) | try baseApp.register(collection: cntrlSignatureType()) | ||||
| try baseApp.register(collection: cntrlSMSCCode()) | |||||
| try baseApp.register(collection: cntrlState()) | try baseApp.register(collection: cntrlState()) | ||||
| try baseApp.register(collection: cntrlStatus()) | try baseApp.register(collection: cntrlStatus()) | ||||
| try baseApp.register(collection: cntrlValueType()) | |||||
| try baseApp.register(collection: cntrlViscosity()) | try baseApp.register(collection: cntrlViscosity()) | ||||
| try baseApp.register(collection: cntrlCompartment()) | try baseApp.register(collection: cntrlCompartment()) | ||||
| try baseApp.register(collection: cntrlCompartmentLocation()) | try baseApp.register(collection: cntrlCompartmentLocation()) | ||||
| try baseApp.register(collection: cntrlContact()) | try baseApp.register(collection: cntrlContact()) | ||||
| try baseApp.register(collection: cntrlContactInfo()) | try baseApp.register(collection: cntrlContactInfo()) | ||||
| try baseApp.register(collection: cntrlContactType()) | |||||
| try baseApp.register(collection: cntrlCustomer()) | try baseApp.register(collection: cntrlCustomer()) | ||||
| try baseApp.register(collection: cntrlEquipment()) | try baseApp.register(collection: cntrlEquipment()) | ||||
| try baseApp.register(collection: cntrlMake()) | try baseApp.register(collection: cntrlMake()) | ||||
| try baseApp.register(collection: cntrlModel()) | try baseApp.register(collection: cntrlModel()) | ||||
| try baseApp.register(collection: cntrlObjProperty()) | try baseApp.register(collection: cntrlObjProperty()) | ||||
| try baseApp.register(collection: cntrlProduct()) | try baseApp.register(collection: cntrlProduct()) | ||||
| try baseApp.register(collection: cntrlItem()) | |||||
| try baseApp.register(collection: cntrlItemResponseType()) | |||||
| try baseApp.register(collection: cntrlLabSetting()) | |||||
| try baseApp.register(collection: cntrlXFluidViscosity()) | |||||
| try baseApp.register(collection: cntrlXUserRole()) | |||||
| try baseApp.register(collection: cntrlXWorkOrderSegment()) | |||||
| try baseApp.register(collection: cntrlOilSample()) | |||||
| try baseApp.register(collection: cntrlSpec()) | |||||
| try baseApp.register(collection: cntrlSpecItem()) | |||||
| try baseApp.register(collection: cntrlSpecItemValue()) | |||||
| try baseApp.register(collection: cntrlWorkOrder()) | |||||