Adding Swift Vapor Fluent Foreign Key Constraint with PostgreSQL
When I run this steam running prepare command line , I get correct tables, but no foreign key constraints are added.
I have a Theme class and a Question class:
Subject: Name, ID
Question: title, I would, theme_id
This is the database preparation function in my Question class:
static func prepare(_ database: Database) throws {
try database.create("questions") { questions in
questions.id()
questions.string("title")
questions.parent(Theme.self, optional: false)
}
}
+3
source to share
2 answers