an error is reported when using SQLite.swift to use try db.run on existing database tables (table.addColumn (title)) adds a title column.
the code is as follows:
/ / create a table
private func creatTable(filePath: String) {
do {
db = try Connection(filePath)
try db.run(table.create(ifNotExists: true){ t in
t.column(statusId, primaryKey: true) //
t.column(statusText)
t.column(userId, unique: true) //
t.column(createTime)
})
try db.run(table.addColumn(title))
print("")
} catch {
print(": \(error)")
}
}
error log:
failed to build table: duplicate column name: title (code: 1)
by looking at the database under sandboxie, the title column has been added, and the data title column you just added is also valuable
.
it should be my wrong use of addColumn, and please give me some advice.