Skip to content

Commit

Permalink
Documentation for #689
Browse files Browse the repository at this point in the history
  • Loading branch information
groue committed Feb 14, 2020
1 parent a5b2757 commit 1f4b374
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions GRDB/QueryInterface/Schema/TableDefinition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ public final class TableAlteration {
/// Renames a column in a table.
///
/// try db.alter(table: "player") { t in
/// t.rename(column: "url", to: "home_url")
/// t.rename(column: "url", to: "homeURL")
/// }
///
/// See https://www.sqlite.org/lang_altertable.html
Expand All @@ -705,7 +705,7 @@ public final class TableAlteration {
/// Renames a column in a table.
///
/// try db.alter(table: "player") { t in
/// t.rename(column: "url", to: "home_url")
/// t.rename(column: "url", to: "homeURL")
/// }
///
/// See https://www.sqlite.org/lang_altertable.html
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3911,15 +3911,17 @@ Other **table constraints** can involve several columns:

### Modify Tables

SQLite lets you rename tables, and add columns to existing tables:
SQLite lets you modify existing tables:

```swift
// ALTER TABLE referer RENAME TO referrer
try db.rename(table: "referer", to: "referrer")

// ALTER TABLE player ADD COLUMN url TEXT
// ALTER TABLE player ADD COLUMN hasBonus BOOLEAN
// ALTER TABLE player RENAME COLUMN url TO homeURL
try db.alter(table: "player") { t in
t.add(column: "url", .text)
t.add(column: "hasBonus", .boolean)
t.rename(column: "url", to: "homeURL") // SQLite 3.25+
}
```

Expand Down

0 comments on commit 1f4b374

Please sign in to comment.