Add dynamic schema
Overview
- Adds some changes to the Cube schema to facilitate multiple databases.
- It is likely we'll decide to store each project's events in its own Clickhouse database.
- This MR adds a
Jitsu
schema which reads events from thejitsu
table on an individual database passed through to cube's security context object. - Also adds some minor changes to the README to help its use.
Note: This change is open to SQL injection (passing another table in to the security context!) and has not implemented any form of sensible authentication yet! (That's coming next...)
How to use
- In Cube, alter the security context of a query to the following variables where:
-
iat
is a Unix timestamp set to later today -
exp
is a Unix timestamp somewhere in the future -
appId
is the name of a Clickhouse database that contains data streamed to it from Jitsu in to a table namedjitsu
. - Make some regular queries to check that it works, changing
appId
to valid, and invalid values to check that it switches databases as expected when querying.
Will this break my devkit?
Yes, initially. Once this hits main
, you'll need to:
- Rename your Clickhouse database to
someproject_1000.jitsu
- In the cube playground, use security contexts and add
"appId": "someproject_1000"
to it. - Update your Jitsu setup to pass data to that new database.
Edited by Robert Hunt