Kitura / Swift-Kuery-ORM

An ORM for Swift, built on Codable
Apache License 2.0
212 stars 30 forks source link

A way to create a table with unique constraints. #112

Open joemichels opened 5 years ago

joemichels commented 5 years ago

Context and Description

It would be handy to identify what columns should have the Unique Constraint at the time of the table creation.

As an example:

var uniqueColumns:[ String] = ["email", "identifierForVendor"]

createTableSync(using db: Database?, uniqueColumnNames: uniqueColumns)

There may be a vastly better way of doing this or a way already, but I hope you understand the need I would like to have.

Environment Details

MacOS 10.14, Xcode 10.2

Expected vs. Actual Behaviour

kilnerm commented 5 years ago

@joemichels Currently if you want constraints like this on tables related to your models you would need to create your table through the SwiftKuery API.

I agree that having some means to describe these constraints within the Model declaration would be helpful so will move this onto the backlog for consideration in the future.