Repository navigation
feat(evault): eVault manifests and vault type in /whois #1190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
39 changes: 39 additions & 0 deletions
39
infrastructure/evault-core/src/core/db/migrations/add-user-ename-constraint.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /** | ||
| * Neo4j Migration: make User.eName unique | ||
| * | ||
| * The per-eName User node is the lock eVault manifests are pinned under, and | ||
| * a concurrent MERGE only guarantees uniqueness when a constraint backs it. | ||
| * Duplicate nodes left by earlier races are folded into one first, the old | ||
| * plain index is dropped, and the constraint (which brings its own index) | ||
| * replaces it. | ||
| */ | ||
|
|
||
| import type { Driver } from "neo4j-driver"; | ||
|
|
||
| export async function createUserENameConstraint(driver: Driver): Promise<void> { | ||
| const session = driver.session(); | ||
| try { | ||
| await session.run( | ||
| `MATCH (u:User) | ||
| WHERE u.eName IS NOT NULL | ||
| WITH u.eName AS eName, collect(u) AS nodes | ||
| WHERE size(nodes) > 1 | ||
| WITH head(nodes) AS keep, tail(nodes) AS dupes | ||
| UNWIND dupes AS d | ||
| SET keep.publicKeys = reduce( | ||
| acc = coalesce(keep.publicKeys, []), | ||
| k IN coalesce(d.publicKeys, []) | | ||
| CASE WHEN k IN acc THEN acc ELSE acc + k END), | ||
| keep.vaultType = coalesce(keep.vaultType, d.vaultType), | ||
| keep.manifestId = coalesce(keep.manifestId, d.manifestId), | ||
| keep.manifestPinnedAt = coalesce(keep.manifestPinnedAt, d.manifestPinnedAt) | ||
| DETACH DELETE d`, | ||
| ); | ||
| await session.run(`DROP INDEX user_ename_index IF EXISTS`); | ||
| await session.run( | ||
| `CREATE CONSTRAINT user_ename_unique IF NOT EXISTS FOR (u:User) REQUIRE u.eName IS UNIQUE`, | ||
| ); | ||
| } finally { | ||
| await session.close(); | ||
| } | ||
| } |
34 changes: 0 additions & 34 deletions
34
infrastructure/evault-core/src/core/db/migrations/add-user-index.ts
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.