Pre: Remove ancient Clojure code comments.
This commit is contained in:
parent
3cba87c74b
commit
e5e37178af
1 changed files with 0 additions and 83 deletions
83
db/src/db.rs
83
db/src/db.rs
|
@ -271,89 +271,6 @@ pub fn create_current_version(conn: &mut rusqlite::Connection) -> Result<DB> {
|
|||
Ok(db)
|
||||
}
|
||||
|
||||
// (def v2-statements v1-statements)
|
||||
|
||||
// (defn create-temp-tx-lookup-statement [table-name]
|
||||
// // n.b., v0/value_type_tag0 can be NULL, in which case we look up v from datoms;
|
||||
// // and the datom columns are NULL into the LEFT JOIN fills them in.
|
||||
// // The table-name is not escaped in any way, in order to allow r#"temp.dotted" names.
|
||||
// // TODO: update comment about sv.
|
||||
// [(str r#"CREATE TABLE IF NOT EXISTS r#" table-name
|
||||
// r#" (e0 INTEGER NOT NULL, a0 SMALLINT NOT NULL, v0 BLOB NOT NULL, tx0 INTEGER NOT NULL, added0 TINYINT NOT NULL,
|
||||
// value_type_tag0 SMALLINT NOT NULL,
|
||||
// index_avet0 TINYINT, index_vaet0 TINYINT,
|
||||
// index_fulltext0 TINYINT,
|
||||
// unique_value0 TINYINT,
|
||||
// sv BLOB,
|
||||
// svalue_type_tag SMALLINT,
|
||||
// rid INTEGER,
|
||||
// e INTEGER, a SMALLINT, v BLOB, tx INTEGER, value_type_tag SMALLINT)")])
|
||||
|
||||
// (defn create-temp-tx-lookup-eavt-statement [idx-name table-name]
|
||||
// // Note that the consuming code creates and drops the indexes
|
||||
// // manually, which makes insertion slightly faster.
|
||||
// // This index prevents overlapping transactions.
|
||||
// // The idx-name and table-name are not escaped in any way, in order
|
||||
// // to allow r#"temp.dotted" names.
|
||||
// // TODO: drop added0?
|
||||
// [(str r#"CREATE UNIQUE INDEX IF NOT EXISTS r#"#,
|
||||
// idx-name
|
||||
// r#" ON r#"#,
|
||||
// table-name
|
||||
// r#" (e0, a0, v0, added0, value_type_tag0) WHERE sv IS NOT NULL")])
|
||||
|
||||
// (defn <create-current-version
|
||||
// [db bootstrapper]
|
||||
// (println r#"Creating database at" current-version)
|
||||
// (s/in-transaction!
|
||||
// db
|
||||
// #(go-pair
|
||||
// (doseq [statement v2-statements]
|
||||
// (try
|
||||
// (<? (s/execute! db [statement]))
|
||||
// (catch #?(:clj Throwable :cljs js/Error) e
|
||||
// (throw (ex-info r#"Failed to execute statement" {:statement statement} e)))))
|
||||
// (<? (bootstrapper db 0))
|
||||
// (<? (s/set-user-version db current-version))
|
||||
// [0 (<? (s/get-user-version db))])))
|
||||
|
||||
|
||||
// (defn <update-from-version
|
||||
// [db from-version bootstrapper]
|
||||
// {:pre [(> from-version 0)]} // Or we'd create-current-version instead.
|
||||
// {:pre [(< from-version current-version)]} // Or we wouldn't need to update-from-version.
|
||||
// (println r#"Upgrading database from" from-version r#"to" current-version)
|
||||
// (s/in-transaction!
|
||||
// db
|
||||
// #(go-pair
|
||||
// // We must only be migrating from v1 to v2.
|
||||
// (let [statement r#"UPDATE parts SET idx = idx + 2 WHERE part = ?"]
|
||||
// (try
|
||||
// (<? (s/execute!
|
||||
// db
|
||||
// [statement :db.part/db]))
|
||||
// (catch #?(:clj Throwable :cljs js/Error) e
|
||||
// (throw (ex-info r#"Failed to execute statement" {:statement statement} e)))))
|
||||
// (<? (bootstrapper db from-version))
|
||||
// (<? (s/set-user-version db current-version))
|
||||
// [from-version (<? (s/get-user-version db))])))
|
||||
|
||||
// (defn <ensure-current-version
|
||||
// r#"Returns a pair: [previous-version current-version]."#,
|
||||
// [db bootstrapper]
|
||||
// (go-pair
|
||||
// (let [v (<? (s/get-user-version db))]
|
||||
// (cond
|
||||
// (= v current-version)
|
||||
// [v v]
|
||||
|
||||
// (= v 0)
|
||||
// (<? (<create-current-version db bootstrapper))
|
||||
|
||||
// (< v current-version)
|
||||
// (<? (<update-from-version db v bootstrapper))))))
|
||||
// */
|
||||
|
||||
pub fn ensure_current_version(conn: &mut rusqlite::Connection) -> Result<DB> {
|
||||
if rusqlite::version_number() < MIN_SQLITE_VERSION {
|
||||
panic!("Mentat requires at least sqlite {}", MIN_SQLITE_VERSION);
|
||||
|
|
Loading…
Reference in a new issue