diff --git a/Sources/App/Models/BaseTables/mdlSysCategory.swift b/Sources/App/Models/BaseTables/mdlSysCategory.swift new file mode 100644 index 0000000..50d7c0e --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlSysCategory.swift @@ -0,0 +1,105 @@ +// +// mdlSysUnit.swift +// +// +// Created by Michiel Carman on 2/16/24. +// + + +import Fluent +import Vapor +import Foundation +import FluentKit + +final class mdlSysCategory: Model, Content { + static let schema = "sysCategory" + + @ID(custom: "id", generatedBy: .database) var id: Int? + + @Field(key: "name") var name: String? + @Field(key: "description") var description: String? + + @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, + createuserid: Int? = nil, + updateuserid: Int? = nil + ) { + self.id = id + self.name = name + self.description = description + self.createuserid = createuserid + self.updateuserid = updateuserid + } +} +extension mdlSysCategory{ + struct Create: AsyncMigration { + func prepare(on database: Database) async throws { + try await database.schema("sysCategory") + .field("id", .int, .identifier(auto: true)) + .field("name", .string) + .field("description", .string) + .field("createDate", .datetime) + .field("createUserId", .int) + .field("updateDate", .datetime) + .field("updateUserId", .int) + .create() + } + + func revert(on database: Database) async throws { + try await database.schema("sysCategory").delete() + } + } + struct Seed: AsyncMigration{ + func prepare(on database: FluentKit.Database) async throws { + let mdls: [mdlSysCategory] = [ + .init(id: 1, + name: "LENGTH", + description: "Unit of distance.", + createuserid: -1, + updateuserid: -1), + .init(id: 1, + name: "WEIGHT", + description: "Unit of force.", + createuserid: -1, + updateuserid: -1), + .init(id: 1, + name: "CAPACITY", + description: "Unit of capacity.", + createuserid: -1, + updateuserid: -1), + .init(id: 1, + name: "VOLUME", + description: "Unit of volume.", + createuserid: -1, + updateuserid: -1), + .init(id: 1, + name: "AREA", + description: "Unit of area.", + createuserid: -1, + updateuserid: -1), + .init(id: 1, + name: "TEMPERATURE", + description: "Unit of temperature.", + createuserid: -1, + updateuserid: -1) + ] + for mdl in mdls{ + try await mdl.save(on: database) + } + + } + + func revert(on database: Database) async throws { + try await mdlSysCategory.query(on: database).delete() + } + } +} + diff --git a/Sources/App/Models/BaseTables/mdlSysOfMeasure.swift b/Sources/App/Models/BaseTables/mdlSysOfMeasure.swift new file mode 100644 index 0000000..16cbda8 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlSysOfMeasure.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 5/6/24. +// + +import Foundation diff --git a/Sources/App/Models/BaseTables/mdlSysUOM.swift b/Sources/App/Models/BaseTables/mdlSysUOM.swift new file mode 100644 index 0000000..16cbda8 --- /dev/null +++ b/Sources/App/Models/BaseTables/mdlSysUOM.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 5/6/24. +// + +import Foundation diff --git a/Sources/App/Models/mdlLocale.swift b/Sources/App/Models/mdlLocale.swift new file mode 100644 index 0000000..744b960 --- /dev/null +++ b/Sources/App/Models/mdlLocale.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 5/14/24. +// + +import Foundation diff --git a/Sources/App/Models/mdlTblValue.swift b/Sources/App/Models/mdlTblValue.swift new file mode 100644 index 0000000..744b960 --- /dev/null +++ b/Sources/App/Models/mdlTblValue.swift @@ -0,0 +1,8 @@ +// +// File.swift +// +// +// Created by Michiel Carman on 5/14/24. +// + +import Foundation