TableAlteration
public final class TableAlteration
The TableAlteration class lets you alter database tables.
You don’t create instances of this class. Instead, you use the Database
alter(table:) method:
try db.alter(table: "player") { t in // t is TableAlteration
t.add(column: ...)
}
-
Appends a column to the table.
try db.alter(table: "player") { t in t.add(column: "url", .text) }Declaration
Swift
@discardableResult public func add(column name: String, _ type: Database.ColumnType? = nil) -> ColumnDefinitionParameters
namethe column name.
typethe column type.
Return Value
An ColumnDefinition that allows you to refine the column definition.
-
Renames a column in a table.
try db.alter(table: "player") { t in t.rename(column: "url", to: "homeURL") } -
Renames a column in a table.
try db.alter(table: "player") { t in t.rename(column: "url", to: "homeURL") }Declaration
Swift
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *) public func rename(column name: String, to newName: String)Parameters
namethe column name to rename.
newNamethe new name of the column.
View on GitHub
Install in Dash
TableAlteration Class Reference