canvasxyz/canvas

Add an $indexed_at field to ModelDB tables managed by Core

Closed this issue · 1 comments

Part 1:

Sometimes it's useful to know when an action was indexed by a Canvas node.

  • When applying an action's effects, in every write to a user-defined model table, we should also write the current time at $indexed_at (as a unix time).
  • We should filter out $indexed_at when calling db.get() from inside the runtime. (This might involve some type changes since db.get() inside vs. outside the runtime will now return different values.)
  • We should zero out $indexed_at when constructing snapshots.

Part 2:

Merging this change will break existing apps' data stores, and require SQLite/IndexedDB/etc. tables to be regenerated. After finishing this change and before releasing it, we should consider implementing migrations on packages/core (in a separate PR).

What should the value of $indexed_at be if two records are merged?