diff --git a/Sources/App/Controllers/TodoController.swift b/Sources/App/Controllers/TodoController.swift index 7096a76..a9b57d9 100644 --- a/Sources/App/Controllers/TodoController.swift +++ b/Sources/App/Controllers/TodoController.swift @@ -3,10 +3,10 @@ import Vapor struct TodoController: RouteCollection { func boot(routes: RoutesBuilder) throws { - let todos = routes.grouped("todos") + let todos = routes.grouped("match") todos.get(use: index) todos.post(use: create) - todos.group(":todoID") { todo in + todos.group(":matchID") { todo in todo.delete(use: delete) } } @@ -21,7 +21,7 @@ struct TodoController: RouteCollection { } func delete(req: Request) throws -> EventLoopFuture { - return Todo.find(req.parameters.get("todoID"), on: req.db) + return Todo.find(req.parameters.get("matchID"), on: req.db) .unwrap(or: Abort(.notFound)) .flatMap { $0.delete(on: req.db) } .transform(to: .ok) diff --git a/Sources/App/Migrations/CreateMatch.swift b/Sources/App/Migrations/CreateMatch.swift new file mode 100644 index 0000000..a426e96 --- /dev/null +++ b/Sources/App/Migrations/CreateMatch.swift @@ -0,0 +1,19 @@ +import Fluent + +struct CreateMatch: Migration { + func prepare(on database: Database) -> EventLoopFuture { + return database.schema("match") + .id() + .field("map", .string) + .field("win", .bool) + .field("date", .bool) + .field("roundsWon", .int) + .field("roundsLost", .int) + + .create() + } + + func revert(on database: Database) -> EventLoopFuture { + return database.schema("matches").delete() + } +} diff --git a/Sources/App/Migrations/CreateTodo.swift b/Sources/App/Migrations/CreateTodo.swift deleted file mode 100644 index f06a4cd..0000000 --- a/Sources/App/Migrations/CreateTodo.swift +++ /dev/null @@ -1,14 +0,0 @@ -import Fluent - -struct CreateTodo: Migration { - func prepare(on database: Database) -> EventLoopFuture { - return database.schema("todos") - .id() - .field("title", .string, .required) - .create() - } - - func revert(on database: Database) -> EventLoopFuture { - return database.schema("todos").delete() - } -} diff --git a/Sources/App/configure.swift b/Sources/App/configure.swift index aa3f805..96e6238 100644 --- a/Sources/App/configure.swift +++ b/Sources/App/configure.swift @@ -9,13 +9,13 @@ public func configure(_ app: Application) throws { app.databases.use(.postgres( hostname: Environment.get("DATABASE_HOST") ?? "localhost", - username: Environment.get("DATABASE_USERNAME") ?? "vapor_username", - password: Environment.get("DATABASE_PASSWORD") ?? "vapor_password", - database: Environment.get("DATABASE_NAME") ?? "vapor_database" + username: Environment.get("DATABASE_USERNAME") ?? "fanosphere", + password: Environment.get("DATABASE_PASSWORD") ?? "pw4fanosphere", + database: Environment.get("DATABASE_NAME") ?? "codmw" ), as: .psql) - app.migrations.add(CreateTodo()) + app.migrations.add(CreateMatch()) // register routes try routes(app) -} \ No newline at end of file +}