mirror of
https://github.com/status-im/sourcecred.git
synced 2025-02-17 06:56:36 +00:00
mirror: add primitives
table for EAV migration (#1340)
Summary: See #1313 for context. The plan is to set up dual-writes with `extract` calls still reading from the old tables until the new ones are complete and tested. The primary risk to production would be a fatal exception in the new write paths, which seems like an acceptable risk. Test Plan: Unit tests pass. wchargin-branch: mirror-eav-schema
This commit is contained in:
parent
976afb6665
commit
0418dfe9dd
@ -145,6 +145,10 @@ export class Mirror {
|
||||
* efficiently in both space and time (see discussion on #883 for
|
||||
* some options).
|
||||
*
|
||||
* NOTE: A migration is underway to switch from type-specific
|
||||
* primitive tables to a single entity-attribute-value table
|
||||
* storing primitives for all types. See issue #1313 for details.
|
||||
*
|
||||
* We refer to node and primitive data together as "own data", because
|
||||
* this is the data that can be queried uniformly for all elements of
|
||||
* a type; querying connection data, by contrast, requires the
|
||||
@ -192,7 +196,7 @@ export class Mirror {
|
||||
// it requires bumping the version, bump it: requiring some extra
|
||||
// one-time cache resets is okay; doing the wrong thing is not.
|
||||
const blob = stringify({
|
||||
version: "MIRROR_v3",
|
||||
version: "MIRROR_v4",
|
||||
schema: this._schema,
|
||||
options: {
|
||||
blacklistedIds: this._blacklistedIds,
|
||||
@ -253,6 +257,20 @@ export class Mirror {
|
||||
FOREIGN KEY(last_update) REFERENCES updates(rowid)
|
||||
)
|
||||
`,
|
||||
dedent`\
|
||||
CREATE TABLE primitives (
|
||||
rowid INTEGER PRIMARY KEY,
|
||||
object_id TEXT NOT NULL,
|
||||
fieldname TEXT NOT NULL,
|
||||
value, -- JSON string, or SQL 0 or 1 for nest fields
|
||||
UNIQUE(object_id, fieldname),
|
||||
FOREIGN KEY(object_id) REFERENCES objects(id)
|
||||
)
|
||||
`,
|
||||
dedent`\
|
||||
CREATE UNIQUE INDEX idx_primitives__object_id__fieldname
|
||||
ON primitives (object_id, fieldname)
|
||||
`,
|
||||
dedent`\
|
||||
CREATE TABLE links (
|
||||
rowid INTEGER PRIMARY KEY,
|
||||
|
@ -146,6 +146,7 @@ describe("graphql/mirror", () => {
|
||||
"meta",
|
||||
"updates",
|
||||
"objects",
|
||||
"primitives",
|
||||
"links",
|
||||
"connections",
|
||||
"connection_entries",
|
||||
|
Loading…
x
Reference in New Issue
Block a user