This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-20
Channels
- # adventofcode (8)
- # aleph (2)
- # announcements (10)
- # aws (5)
- # aws-lambda (2)
- # babashka (23)
- # beginners (23)
- # biff (9)
- # calva (4)
- # cider (8)
- # clj-kondo (21)
- # clojure (77)
- # clojure-boston (1)
- # clojure-dev (50)
- # clojure-europe (36)
- # clojure-gamedev (3)
- # clojure-nl (1)
- # clojure-norway (3)
- # clojure-spec (33)
- # clojure-uk (3)
- # clojurescript (22)
- # core-async (3)
- # cursive (10)
- # datahike (18)
- # datalevin (1)
- # datascript (9)
- # deps-new (21)
- # emacs (11)
- # events (1)
- # graphql (11)
- # guix (26)
- # java (7)
- # jobs (3)
- # lsp (12)
- # malli (6)
- # pathom (33)
- # pedestal (3)
- # polylith (15)
- # reagent (5)
- # releases (3)
- # remote-jobs (1)
- # scittle (9)
- # sql (27)
- # tools-build (9)
- # vim (7)
How can I change/alter/update the database schema in a DataScript database? I saw a tip about replacing the :schema entry, but it doesn't work, there seem to be more about it (there is an :rschema entry also which is not updated?).
Thanks. Is there a way to trigger automatic recalc of rschema or I have to do it manually? Maybe it is easer to reload the data in a new DB?
I re-built the :rschema and it works when adding data, I guess that is the one actually used. I was just thinking along possibilities to allow a user to add data and custom types successively.
> Maybe it is easer to reload the data in a new DB? Depends on how much data :) But basically the reason why there’s no official API for schema migrations is because it’s hard to ensure constraints between schemas. E.g. if you change multi-arity to single-arity, someone has to guarantee that there are no multi-arity values left in the database
I see that a schema change has to be accompanied by a transaction that makes the database consistent with the constraints, so in practice it is a transaction including the schema into a new valid state. It is an interesting problem how to generate the necessary transaction for a schema change.
Docs describe a trial and error process to change data until computer says yes. Maybe some tool could automatically suggest a destructive or not transformation of the data based on the schema change. "Attempting a schema change that violates an invariant will cause the transaction to abort with an exception. To enable such change, first change your data so the invariant you want becomes true."