I'm writing a web service in Swift using Vapor 3. I'm using FluentPostgreSQL
for data persistence. I have a user model which conforms to both PostgreSQLModel, PostgreSQLMigration
. The app builds correctly. However, when I run the app, I am getting the following error.
Fatal error: Error raised at top level: ⚠️ PostgreSQL Error: database "trialService" does not exist
- id: PostgreSQLError.server.fatal.InitPostgres
This is how my configure.swift
looks like.
try services.register(FluentPostgreSQLProvider())
let configPSQL = PostgreSQLDatabaseConfig(hostname: "localhost", username: "imthath", database: "trialService")
let psql = PostgreSQLDatabase(config: configPSQL)
var databases = DatabasesConfig()
databases.add(database: sqlite, as: .sqlite)
databases.add(database: psql, as: .psql)
services.register(databases)
As you can see I was earlier using SQLite and now I am trying to use PostgreSQL for some models including User. I did not get any error when I was only SQLite.
您需要在Vapor应用程序连接到终端之前从终端创建数据库:
createdb trialService
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.