-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(backend): Start work redefining the event db for catalyst voices.
- Loading branch information
Showing
2 changed files
with
177 additions
and
190 deletions.
There are no files selected for viewing
91 changes: 28 additions & 63 deletions
91
catalyst-gateway/event-db/migrations/V1__config_tables.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,46 @@ | ||
-- Catalyst Event Database | ||
|
||
-- Version of the schema. | ||
CREATE TABLE IF NOT EXISTS | ||
refinery_schema_history ( | ||
VERSION INTEGER NOT NULL PRIMARY KEY, | ||
NAME VARCHAR(255), | ||
applied_on VARCHAR(255), | ||
checksum VARCHAR(255) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS refinery_schema_history | ||
( | ||
version INTEGER NOT NULL PRIMARY KEY, | ||
name VARCHAR(255), | ||
applied_on VARCHAR(255), | ||
checksum VARCHAR(255) | ||
); | ||
|
||
COMMENT ON TABLE refinery_schema_history IS | ||
'History of Schema Updates to the Database. | ||
Managed by the `refinery` cli tool. | ||
'; | ||
COMMENT ON TABLE refinery_schema_history IS 'History of Schema Updates to the Database. | ||
Managed by the `refinery` cli tool.'; | ||
|
||
-- Config Table | ||
-- This table is looked up with three keys, `id`, `id2` and `id3` | ||
|
||
CREATE TABLE config | ||
( | ||
row_id SERIAL PRIMARY KEY, | ||
id VARCHAR NOT NULL, | ||
id2 VARCHAR NOT NULL, | ||
id3 VARCHAR NOT NULL, | ||
value JSONB NULL | ||
); | ||
CREATE TABLE | ||
config ( | ||
row_id SERIAL PRIMARY KEY, | ||
id VARCHAR NOT NULL, | ||
id2 VARCHAR NOT NULL, | ||
id3 VARCHAR NOT NULL, | ||
VALUE JSONB NULL | ||
); | ||
|
||
-- id+id2+id3 must be unique, they are a combined key. | ||
CREATE UNIQUE INDEX config_idx ON config(id,id2,id3); | ||
CREATE UNIQUE INDEX config_idx ON config (id, id2, id3); | ||
|
||
COMMENT ON TABLE config IS | ||
'General JSON Configuration and Data Values. | ||
COMMENT ON TABLE config IS 'General JSON Configuration and Data Values. | ||
Defined Data Formats: | ||
API Tokens: | ||
`id` = "api_token" | ||
`id2` = <API Token, encrypted with a secret, as base-64 encoded string "">` | ||
`id3` = "" (Unused), | ||
`value`->"name" = "<Name of the token owner>", | ||
`value`->"created" = <Integer Unix Epoch when Token was created>, | ||
`value`->"expires" = <Integer Unix Epoch when Token will expire>, | ||
`value`->"perms" = {Permissions assigned to this api key} | ||
Community reviewers: | ||
`id` = `email` | ||
`id2` = `encrypted_password` | ||
`id3` = `salt` | ||
`value`->"role" = `role` | ||
`value`->"name" = `name` | ||
`value`->"anonymous_id" = `<anonymous_id of the PA>` | ||
`value`->"force_reset" = "<bool used to force reset of password>" | ||
`value`->"active" = "<bool used to activate account>" | ||
IdeaScale parameters: | ||
`id` = "ideascale" | ||
`id2` = "params" | ||
`id3` = <String identifying a fund, e.g. "F10"> | ||
`value`->"campaign_group_id" = <IdeaScale campaign group id> | ||
`value`->"stage_ids" = <List of IdeaScale stage ids> | ||
Event IdeaScale parameters: | ||
`id` = "event" | ||
`id2` = "ideascale_params" | ||
`id3` = <Event row_id (as a string)> | ||
`value`->"params_id" = <String identifier of the Ideascale parameters in the config table> | ||
Currently None | ||
'; | ||
|
||
COMMENT ON COLUMN config.row_id IS | ||
'Synthetic unique key. | ||
COMMENT ON COLUMN config.row_id IS 'Synthetic unique key. | ||
Always lookup using id.'; | ||
COMMENT ON COLUMN config.id IS 'The name/id of the general config value/variable'; | ||
COMMENT ON COLUMN config.id2 IS | ||
'2nd ID of the general config value. | ||
|
||
COMMENT ON COLUMN config.id IS 'The name/id of the general config value/variable'; | ||
|
||
COMMENT ON COLUMN config.id2 IS '2nd ID of the general config value. | ||
Must be defined, use "" if not required.'; | ||
COMMENT ON COLUMN config.id3 IS | ||
'3rd ID of the general config value. | ||
|
||
COMMENT ON COLUMN config.id3 IS '3rd ID of the general config value. | ||
Must be defined, use "" if not required.'; | ||
|
||
COMMENT ON COLUMN config.value IS 'The JSON value of the system variable id.id2.id3'; | ||
|
||
COMMENT ON INDEX config_idx IS 'We use three keys combined uniquely rather than forcing string concatenation at the app level to allow for querying groups of data.'; |
Oops, something went wrong.