mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
GRDBDemoiOS: use table creation DSL
This commit is contained in:
1 parent
7d21772f87
commit
358b823e00
2 files changed
+6
-8
No files matched your search
@@ -28,13 +28,11 @@ func setupDatabase(application: UIApplication) {
|
||||
migrator.registerMigration("createPersons") { db in
|
||||
// Have person names compared in a localized case insensitive fashion
|
||||
// See https://github.com/groue/GRDB.swift/#unicode
|
||||
let collation = DatabaseCollation.localizedCaseInsensitiveCompare
|
||||
try db.execute(
|
||||
"CREATE TABLE persons (" +
|
||||
"id INTEGER PRIMARY KEY, " +
|
||||
"name TEXT NOT NULL COLLATE \(collation.name), " +
|
||||
"score INTEGER NOT NULL " +
|
||||
")")
|
||||
try db.create(table: "persons") { t in
|
||||
t.column("id", .Integer).primaryKey()
|
||||
t.column("name", .Text).notNull().collate(.localizedCaseInsensitiveCompare)
|
||||
t.column("score", .Integer).notNull()
|
||||
}
|
||||
}
|
||||
|
||||
migrator.registerMigration("addPersons") { db in
|
||||
|
||||
@@ -187,7 +187,7 @@ extension PersonsViewController {
|
||||
@IBAction func stressTest() {
|
||||
setEditing(false, animated: true)
|
||||
|
||||
for _ in 0..<1000 {
|
||||
for _ in 0..<50 {
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
|
||||
try! dbQueue.inTransaction { db in
|
||||
if Person.fetchCount(db) == 0 {
|
||||
|
||||
Reference in new issue
Block a user