-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1148 from stephencelis/schemachanger-part-2
schemachanger-part-2
- Loading branch information
Showing
20 changed files
with
966 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ build: | |
|
||
lint: | ||
swiftlint --strict | ||
lint-fix: | ||
swiftlint lint fix | ||
|
||
test: | ||
ifdef XCPRETTY | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Foundation | ||
|
||
enum SQLiteFeature { | ||
case partialIntegrityCheck // PRAGMA integrity_check(table) | ||
case sqliteSchemaTable // sqlite_master => sqlite_schema | ||
case renameColumn // ALTER TABLE ... RENAME COLUMN | ||
case dropColumn // ALTER TABLE ... DROP COLUMN | ||
|
||
func isSupported(by version: SQLiteVersion) -> Bool { | ||
switch self { | ||
case .partialIntegrityCheck, .sqliteSchemaTable: | ||
return version >= .init(major: 3, minor: 33) | ||
case .renameColumn: | ||
return version >= .init(major: 3, minor: 25) | ||
case .dropColumn: | ||
return version >= .init(major: 3, minor: 35) | ||
} | ||
} | ||
} | ||
|
||
extension Connection { | ||
func supports(_ feature: SQLiteFeature) -> Bool { | ||
feature.isSupported(by: sqliteVersion) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Foundation | ||
|
||
public struct SQLiteVersion: Comparable, CustomStringConvertible { | ||
public let major: Int | ||
public let minor: Int | ||
public var point: Int = 0 | ||
|
||
public var description: String { | ||
"SQLite \(major).\(minor).\(point)" | ||
} | ||
|
||
public static func <(lhs: SQLiteVersion, rhs: SQLiteVersion) -> Bool { | ||
lhs.tuple < rhs.tuple | ||
} | ||
|
||
public static func ==(lhs: SQLiteVersion, rhs: SQLiteVersion) -> Bool { | ||
lhs.tuple == rhs.tuple | ||
} | ||
|
||
static var zero: SQLiteVersion = .init(major: 0, minor: 0) | ||
private var tuple: (Int, Int, Int) { (major, minor, point) } | ||
} |
Oops, something went wrong.