[Bug]: history migration not working
Closed this issue · 0 comments
kordano commented
What version of Datahike are you using?
0.4.1480
What version of Java are you using?
openjdk version "11.0.13" 2021-10-19
What operating system are you using?
Ubuntu 20.04.3 LTS
What database EDN configuration are you using?
{:store {:backend :mem
:id "export"}
:keep-history? true
:schema-flexibility :write
:attribute-refs? false}
Describe the bug
When exporting a database with historical data and importing it into a new database, the historical data like removal and original data are lost.
What is the expected behaviour?
History should be imported as well.
How can the behaviour be reproduced?
(require '[datahike.api :as d])
(require '[datahike.migrate :as m])
(def schema [{:db/ident :name
:db/cardinality :db.cardinality/one
:db/index true
:db/unique :db.unique/identity
:db/valueType :db.type/string}
{:db/ident :parents
:db/cardinality :db.cardinality/many
:db/valueType :db.type/ref}
{:db/ident :age
:db/cardinality :db.cardinality/one
:db/valueType :db.type/long}])
(def export-cfg {:store {:backend :mem
:id "export"}
:keep-history? true
:schema-flexibility :write
:attribute-refs? false})
(do
(d/delete-database export-cfg)
(d/create-database export-cfg))
(def export-conn (d/connect export-cfg))
(d/transact export-conn schema)
(d/transact export-conn {:tx-data [{:name "Alice" :age 25}
{:name "Bob" :age 35}]})
(d/transact export-conn {:tx-data [{:name "Charlie"
:age 5
:parents [[:name "Alice"] [:name "Bob"]]}]})
(d/transact export-conn {:tx-data [{:name "Daisy" :age 20}]})
(d/transact export-conn {:tx-data [{:name "Erhard" :age 20}]})
(d/transact export-conn {:tx-data [[:db/retractEntity [:name "Erhard"]]]})
(datahike.migrate/export-db @export-conn "/tmp/dh.dump")
(def import-cfg {:store {:backend :mem
:id "import"}
:keep-history? true
:schema-flexibility :write
:attribute-refs? false})
(do
(d/delete-database import-cfg)
(d/create-database import-cfg))
(def import-conn (d/connect import-cfg))
(datahike.migrate/import-db import-conn "/tmp/dh.dump")
(= (d/datoms (d/history @export-conn) :eavt)
(d/datoms (d/history @import-conn) :eavt))
;; => false