How to add an index for a column

For the following code:
migrator.registerMigration("creatZipCodes") { db in
try db.create(table: "ZipCodes") { t in
t.autoIncrementedPrimaryKey("zipRowId")
t.column("zipCode", .text).notNull()
t.column("zipState", .text).notNull()
t.column("zipType", .text).notNull()
t.column("zipCity", .text).notNull()
}
}

How do I add an index for "zipCode" column. Do I have to use the sql command CREATE INDEX?

Please search for "create index" in the README: GRDB.swift/README.md at master · groue/GRDB.swift · GitHub

Thanks, I looked at that documentation you mentioned and was wondering if there was another way. At any rate I got the index created as I wanted.

You did not ask this question. So you missed the opportunity to know if "there's another way" :man_shrugging:

Maybe next time you'll directly ask what's in your mind? It will be better for everyone, because we won't spend time writing false questions, or looking for useless answers.

Terms of Service

Privacy Policy

Cookie Policy