prep for statistics table
This commit is contained in:
@@ -1,55 +0,0 @@
|
|||||||
import Fluent
|
|
||||||
|
|
||||||
//struct CreateMatch: Migration {
|
|
||||||
// func prepare(on database: Database) -> EventLoopFuture<Void> {
|
|
||||||
// return database.schema("match")
|
|
||||||
// .id()
|
|
||||||
// .field("map", .string)
|
|
||||||
// .field("win", .bool)
|
|
||||||
// .field("date", .datetime)
|
|
||||||
// .field("roundsWon", .int)
|
|
||||||
// .field("roundsLost", .int)
|
|
||||||
//
|
|
||||||
// .create()
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func revert(on database: Database) -> EventLoopFuture<Void> {
|
|
||||||
// return database.schema("matches").delete()
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
struct AddCasual:Migration{
|
|
||||||
|
|
||||||
|
|
||||||
func prepare(on database: Database) -> EventLoopFuture<Void> {
|
|
||||||
return database.schema("match")
|
|
||||||
.field("competitive",.bool)
|
|
||||||
.field("gameMode",.int)
|
|
||||||
.update()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func revert(on database: Database) -> EventLoopFuture<Void> {
|
|
||||||
return database.schema("match23es").delete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//struct AddCODGame2: Migration {
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// func prepare(on database: Database) -> EventLoopFuture<Void> {
|
|
||||||
// return database.schema("match")
|
|
||||||
// .field("codGame",.string)
|
|
||||||
// .field("notes",.string)
|
|
||||||
// .field("players",.string)
|
|
||||||
// .update()
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func revert(on database: Database) -> EventLoopFuture<Void> {
|
|
||||||
// return database.schema("match23es").delete()
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
92
Sources/App/Migrations/CreateStatistics.swift
Normal file
92
Sources/App/Migrations/CreateStatistics.swift
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
import Fluent
|
||||||
|
|
||||||
|
|
||||||
|
struct CreateStatistics: Migration {
|
||||||
|
// Prepares the database for storing Galaxy models.
|
||||||
|
func prepare(on database: Database) -> EventLoopFuture<Void> {
|
||||||
|
database.schema("statistics")
|
||||||
|
.id()
|
||||||
|
.field("title", .string)
|
||||||
|
.field("wins", .int)
|
||||||
|
.field("losses", .int)
|
||||||
|
.create()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optionally reverts the changes made in the prepare method.
|
||||||
|
func revert(on database: Database) -> EventLoopFuture<Void> {
|
||||||
|
database.schema("statistics").delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//struct CreateMatch: Migration {
|
||||||
|
// func prepare(on database: Database) -> EventLoopFuture<Void> {
|
||||||
|
// return database.schema("match")
|
||||||
|
// .id()
|
||||||
|
// .field("map", .string)
|
||||||
|
// .field("win", .bool)
|
||||||
|
// .field("date", .datetime)
|
||||||
|
// .field("roundsWon", .int)
|
||||||
|
// .field("roundsLost", .int)
|
||||||
|
//
|
||||||
|
// .create()
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// func revert(on database: Database) -> EventLoopFuture<Void> {
|
||||||
|
// return database.schema("matches").delete()
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//struct AddStats:Migration{
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// func prepare(on database: Database) -> EventLoopFuture<Void> {
|
||||||
|
// return database.create(Galaxy.self) { builder in
|
||||||
|
// builder.field(for: \.id, isIdentifier: true)
|
||||||
|
// builder.field(for: \.name)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// func revert(on database: Database) -> EventLoopFuture<Void> {
|
||||||
|
// return database.schema("match23es").delete()
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
|
||||||
|
//struct AddCasual:Migration{
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// func prepare(on database: Database) -> EventLoopFuture<Void> {
|
||||||
|
// return database.schema("match")
|
||||||
|
// .field("competitive",.bool)
|
||||||
|
// .field("gameMode",.int)
|
||||||
|
// .update()
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// func revert(on database: Database) -> EventLoopFuture<Void> {
|
||||||
|
// return database.schema("match23es").delete()
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
//struct AddCODGame2: Migration {
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// func prepare(on database: Database) -> EventLoopFuture<Void> {
|
||||||
|
// return database.schema("match")
|
||||||
|
// .field("codGame",.string)
|
||||||
|
// .field("notes",.string)
|
||||||
|
// .field("players",.string)
|
||||||
|
// .update()
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// func revert(on database: Database) -> EventLoopFuture<Void> {
|
||||||
|
// return database.schema("match23es").delete()
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
39
Sources/App/Models/Statistics.swift
Normal file
39
Sources/App/Models/Statistics.swift
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
//
|
||||||
|
// Statistics.swift
|
||||||
|
// Statistics
|
||||||
|
//
|
||||||
|
// Created by Michael Simard on 8/2/21.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Fluent
|
||||||
|
import Vapor
|
||||||
|
|
||||||
|
final class Statistics: Model {
|
||||||
|
// Name of the table or collection.
|
||||||
|
static let schema = "statistics"
|
||||||
|
|
||||||
|
@ID(key: .id)
|
||||||
|
var id: UUID?
|
||||||
|
|
||||||
|
@Field(key: "title")
|
||||||
|
var title: String
|
||||||
|
|
||||||
|
@Field(key: "Wins")
|
||||||
|
var wins: Int
|
||||||
|
|
||||||
|
@Field(key: "losses")
|
||||||
|
var losses: Int
|
||||||
|
|
||||||
|
|
||||||
|
// Creates a new, empty .
|
||||||
|
init() { }
|
||||||
|
|
||||||
|
// Creates a new with all properties set.
|
||||||
|
init(id: UUID? = nil, title: String, wins: Int, losses: Int) {
|
||||||
|
self.id = id
|
||||||
|
self.title = title
|
||||||
|
self.wins = wins
|
||||||
|
self.losses = losses
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@ public func configure(_ app: Application) throws {
|
|||||||
), as: .psql)
|
), as: .psql)
|
||||||
|
|
||||||
//app.migrations.add(CreateMatch())
|
//app.migrations.add(CreateMatch())
|
||||||
app.migrations.add(AddCasual())
|
app.migrations.add(CreateStatistics())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user