Skip to content

Instantly share code, notes, and snippets.

@groue
Created March 29, 2016 21:03
Show Gist options
  • Save groue/97a5f2c81fb0fbfabc3bd3d13f08feb3 to your computer and use it in GitHub Desktop.
Save groue/97a5f2c81fb0fbfabc3bd3d13f08feb3 to your computer and use it in GitHub Desktop.
func setupDatabase() {
// That "collation" helps us compare person names in a localized case insensitive fashion
let collation = DatabaseCollation.localizedCaseInsensitiveCompare
try! dbQueue.execute(
"CREATE TABLE persons (" +
"id INTEGER PRIMARY KEY, " +
"name TEXT NOT NULL COLLATE \(collation.name), " +
"score INTEGER NOT NULL " +
")")
try! Person(name: "Arthur", score: 250).insert(dbQueue)
try! Person(name: "Barbara", score: 750).insert(dbQueue)
try! Person(name: "Craig", score: 500).insert(dbQueue)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment