Thursday, January 23, 2014

Schema Alteration

Datomic is a database that has flexible, minimal schema. Starting with version 0.9.4470, available here, we have added the ability to alter existing schema attributes after they are first defined. You can alter schema to

  • rename attributes
  • rename your own programmatic identities (uses of :db/ident)
  • add or remove indexes 
  • add or remove uniqueness constraints
  • change attribute cardinality
  • change whether history is retained for an attribute
  • change whether an attribute is treated as a component

Schema alterations use the same transaction API as all other transactions, just as schema installation does.  All schema alterations can be performed while a database is online, without requiring database downtime.  Most schema changes are effective immediately, at the end of the transaction.  There is one exception: adding an index requires a background job to build the new index. You can use the new syncSchema API for detecting when a schema change is available.

When renaming an attribute or identity, you can continue to use the old name as long as you haven't repurposed it. This allows for incremental application updating.

See the schema alteration docs for the details.

Schema alteration has been our most requested enhancement. We hope you find it useful and look forward to your feedback.

8 comments :

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hurray! We have been wanting this for quite some time. Awesome

    ReplyDelete
  3. Oh my wow!!!! There goes the last hurdle. Great news.

    ReplyDelete
  4. In the table of alterations in the schema docs, the "Effect on Attribute" notes for the two :db/noHistory alterations appear to be swapped.

    ReplyDelete