Coder Social home page Coder Social logo

Schema Migration about datahike HOT 8 CLOSED

replikativ avatar replikativ commented on August 29, 2024
Schema Migration

from datahike.

Comments (8)

whilo avatar whilo commented on August 29, 2024

Yes, this is unfortunately true. You can also overwrite the schema in the database yourself, if you know that it is consistent with its current value.

(swap! conn assoc :schema new-schema)
(datahike.api/transact! conn [])

should do the trick.

from datahike.

mgerlach-klick avatar mgerlach-klick commented on August 29, 2024

Oh, good to know! Thank you @whilo !

from datahike.

mgerlach-klick avatar mgerlach-klick commented on August 29, 2024

I don't think this actually works.

I modified a schema to make one attribute :db/isComponent true and swap!ed it in. This had no effect on the queries. I'm guessing I would have to modify (:rschema conn) in some way as well?

from datahike.

whilo avatar whilo commented on August 29, 2024

@mgerlach-klick Yes, that is true. Did it work for you? I haven't found the time yet to figure it out, but we will aim to fix this over the next months with full schema support.

from datahike.

mgerlach-klick avatar mgerlach-klick commented on August 29, 2024

I don't recall. I believe I gave up before I got to that point. Maybe ping me once this is working and I'll give datahike another try?

from datahike.

px0 avatar px0 commented on August 29, 2024

I'm excited about trying v0.2. What's the status on schema migration now?

from datahike.

px0 avatar px0 commented on August 29, 2024

Replying to myself, found this: https://github.com/replikativ/datahike/blob/master/doc/schema.md#migration

from datahike.

tatut avatar tatut commented on August 29, 2024

Adding new attributes to any :db/ident entities seem to fail

(defn dh-update-exception []
  (let [uri "datahike:mem://test"]
    (datahike.api/create-database uri)
    (let [c (datahike.api/connect uri)]
      ;; Add two enum values
      (datahike.api/transact c {:tx-data [{:db/ident :task.status/in-progress}
                                          {:db/ident :task.status/complete}]})

      ;; Later we realize we want to trac which enum values belong together
      (datahike.api/transact c {:tx-data [{:db/ident :enum/attribute
                                           :db/valueType :db.type/keyword
                                           :db/cardinality :db.cardinality/one}]})

      ;; Then we update existing enum values
      (datahike.api/transact c {:tx-data [{:db/ident :task.status/in-progress
                                           :enum/attribute :task/status}
                                          {:db/ident :task.status/complete
                                           :enum/attribute :task/status}]}))))

Running that will throw:

Update not supported for these schema attributes
   {:error :transact/schema,
    :entity
    {:db/ident :task.status/in-progress, :enum/attribute :task/status},
    :invalid-updates #:enum{:attribute [nil :task/status]}}```

from datahike.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.