|
- //
- // mdlLabSetting.swift
- //
- //
- // Created by Michiel Carman on 1/24/24.
- //
-
- import Fluent
- import Vapor
- import Foundation
- import FluentKit
-
- final class mdlLabSetting: Model, Content {
- static let schema = "labSetting"
-
- @ID(custom: "id", generatedBy: .database) var id: Int?
-
- @Field(key: "name") var name: String?
- @Field(key: "description") var description: String?
- @Field(key: "barcodeDelimeter") var barcodedelimeter: String?
- @Field(key: "barcodeActive") var barcodeactive: Bool?
- @Field(key: "textActive") var textactive: Bool?
- @Field(key: "logoActive") var logoactive: Bool?
- @Field(key: "cpcl") var cpcl: String?
-
- @Parent(key: "locationId") var location: mdlLocation
-
-
- @Timestamp(key: "createDate", on: .create) var createdate: Date?
- @Field(key: "createUserId") var createuserid: Int?
- @Timestamp(key: "updateDate", on: .update) var updatedate: Date?
- @Field(key: "updateUserId") var updateuserid: Int?
-
- init() { }
-
- init(id: Int? = nil, name: String? = nil, description: String? = nil, barcodedelimeter: String? = nil, barcodeactive: Bool? = nil, textactive: Bool? = nil, logoactive: Bool? = nil, createuserid: Int? = nil, updateuserid: Int? = nil, cpc: String? = nil) {
- self.id = id
-
- self.name = name
- self.description = description
- self.barcodedelimeter = barcodedelimeter
- self.barcodeactive = barcodeactive
- self.textactive = textactive
- self.logoactive = logoactive
-
- self.createuserid = createuserid
- self.updateuserid = updateuserid
- self.cpcl = cpcl
- }
- }
-
- extension mdlLabSetting{
- struct Create: AsyncMigration {
- func prepare(on database: Database) async throws {
- try await database.schema("labSetting")
- .field("id", .int, .identifier(auto: true))
- .field("name", .string)
- .field("description", .string)
- .field("barcodeDelimeter", .string)
- .field("barcodeActive", .bool)
- .field("textActive", .bool)
- .field("logoActive", .bool)
- .field("createDate", .datetime)
- .field("createUserId", .int)
- .field("updateDate", .datetime)
- .field("updateUserId", .int)
- .create()
- }
-
- func revert(on database: Database) async throws {
- try await database.schema("labSetting").delete()
- }
- }
- struct Mod1: AsyncMigration{
- func prepare(on database: Database) async throws {
- try await database.schema("labSetting")
- .field("cpcl", .string)
- .update()
- }
-
- func revert(on database: Database) async throws {
- try await database.schema("labSetting")
- .deleteField("cpcl")
- .update()
- }
- }
- struct Mod2: AsyncMigration{
- func prepare(on database: Database) async throws {
- try await database.schema("labSetting")
- .field("locationId", .int, .references("location", "id"))
- .update()
- }
-
- func revert(on database: Database) async throws {
- try await database.schema("labSetting")
- .deleteField("locationId")
- .update()
- }
- }
- }
-
-
|