Skip to content

feat(migrate): DB tooling for v1.19.2 -> v2.0.0 (URLs + emails + ACL audit)#1543

Merged
jescalada merged 18 commits into
finos:mainfrom
re-vlad:feat/1535-mongodb-migration
Jun 4, 2026
Merged

feat(migrate): DB tooling for v1.19.2 -> v2.0.0 (URLs + emails + ACL audit)#1543
jescalada merged 18 commits into
finos:mainfrom
re-vlad:feat/1535-mongodb-migration

Conversation

@re-vlad

@re-vlad re-vlad commented May 21, 2026

Copy link
Copy Markdown
Contributor

Description

Upgrade to Git-Proxy v2.0.0 requires database preparation for breaking behavior around exact repo URL lookup (need .git on repos.url) and v2 push authorization based on committer email + User.username ACL entries.
This PR adds operator-run migration scripts with dry-run by default, explicit apply, structured reports, and separate backups so upgrades are safer and repeatable (aligned with issue #1535).

Phase 1 — repo URL normalization: append .git to repos.url where missing (idempotent) via migrate-urls.js + backup-urls.js.
Phase 2 — users & ACL normalization:

  • migrate-users.js always runs email audit + ACL orphan audit (entries in canPush / canAuthorise that don’t resolve to any User.username; no silent ACL rewrite).
  • optional email updates via --apply --csv username,email (lib/csv.js, apply-user-emails.js with post-apply uniqueness simulation).
  • backup-users.js writes backup-users-.json (full snapshot, passwords excluded) and users-email-.csv template for admin edits before apply.
  • docs: The Migration-guide-v1-to-v2.md updated for both phases + csv constraints.

Related Issue

Resolves #1535

Checklist

General

Documentation

  • Documentation has been added/updated for any new features

Configuration

  • If configuration schema (config.schema.json) was modified:
    • TypeScript types regenerated (npm run generate-config-types)
    • Schema reference docs regenerated (npm run gen-schema-doc)

Tests

  • Tests have been added/updated for new functionality
  • Unit tests pass (npm test)
  • Linting and formatting pass (npm run lint and npm run format:check)
  • Type checks pass (npm run check-types)

Note: Migration scripts are one-off operator tooling, not part of the main app bundle. Their unit tests live under scripts/migrate/test/ and are not included in the default npm test run (which targets ./test). Run them separately with:

npm run test:migrate

@re-vlad re-vlad requested a review from a team as a code owner May 21, 2026 14:20
@re-vlad re-vlad self-assigned this May 21, 2026
@netlify

netlify Bot commented May 21, 2026

Copy link
Copy Markdown

Deploy Preview for endearing-brigadeiros-63f9d0 canceled.

Name Link
🔨 Latest commit 4909ff4
🔍 Latest deploy log https://app.netlify.com/projects/endearing-brigadeiros-63f9d0/deploys/6a2062f914d7fd0008bb5e19

@linux-foundation-easycla

linux-foundation-easycla Bot commented May 21, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: re-vlad / name: re-vlad (51384cc)

@re-vlad re-vlad added the enhancement New feature or request label May 21, 2026
@codecov

codecov Bot commented May 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.62%. Comparing base (2beab81) to head (4909ff4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1543   +/-   ##
=======================================
  Coverage   90.62%   90.62%           
=======================================
  Files          69       69           
  Lines        5694     5694           
  Branches      985      985           
=======================================
  Hits         5160     5160           
  Misses        516      516           
  Partials       18       18           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@re-vlad re-vlad force-pushed the feat/1535-mongodb-migration branch from 51384cc to fb1782a Compare May 21, 2026 14:54
@re-vlad re-vlad changed the title feat: v1.19.2 to v2.0.0 repos.url Idempotent normalization: append .git where missing feat(migrate): MongoDB tooling for v1.19.2 → v2.0.0 (URLs + emails + ACL audit) May 27, 2026
Comment thread scripts/migrate/Migration-guide-v1-to-v2.md Outdated
Comment thread scripts/migrate/lib/analyze-users.js Outdated
Comment thread scripts/migrate/test/analyze-users.test.ts Outdated
Comment thread scripts/migrate/lib/analyze-urls.js
Comment thread scripts/migrate/migrate-urls.js Outdated
Comment thread scripts/migrate/lib/common.js Outdated
Comment thread scripts/migrate/lib/common.js Outdated
@re-vlad re-vlad changed the title feat(migrate): MongoDB tooling for v1.19.2 → v2.0.0 (URLs + emails + ACL audit) feat(migrate): MongoDB tooling for v1.19.2 -> v2.0.0 (URLs + emails + ACL audit) May 28, 2026

@Andreybest Andreybest left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok from my side, please check @jescalada comments.
Only 2 things from my side to make it perfect:

  1. TypeScript in migration scripts would be appreciated.
  2. Tests that are run on virtual mongo would show more reliability by using mongodb-memory-server or it's derivatives.

@re-vlad

re-vlad commented May 29, 2026

Copy link
Copy Markdown
Contributor Author
  1. TypeScript in migration scripts would be appreciated.

Agreed. I'll track a follow-up to convert scripts/migrate to TS for consistency with the rest of the repo.

@re-vlad re-vlad requested a review from jescalada May 29, 2026 14:56
re-vlad added 13 commits June 3, 2026 15:10
- Rename URL migration entrypoints to migrate-urls and backup-urls
- Rename analyzer module to lib/analyze-urls
- Make createBackup accept file prefix and data payload
- Update URL migration guide and examples to new names
- avoid generating invalid repo URLs during v1→v2 migration
- normalizing safe cases (trim + strip trailing slashes)
- reporting blank/non-http(s) values as manual-fix issues.
- refactor to reuse one MongoClient per run
- avoid repeated connect/close cycles
+ reword migration docs regarding 'clients' -> 'incoming git HTTP traffic'
@re-vlad re-vlad force-pushed the feat/1535-mongodb-migration branch from 1170f0e to e9d188b Compare June 3, 2026 17:04
@re-vlad re-vlad changed the title feat(migrate): MongoDB tooling for v1.19.2 -> v2.0.0 (URLs + emails + ACL audit) feat(migrate): DB tooling for v1.19.2 -> v2.0.0 (URLs + emails + ACL audit) Jun 3, 2026
@re-vlad

re-vlad commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

@jescalada @andypols @dcoric please re-review and resolve comments

@jescalada jescalada left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@re-vlad LGTM, thanks for the contribution! 🚀

@jescalada jescalada merged commit c841444 into finos:main Jun 4, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Automated MongoDB Migration Script from v1.19.2 to v2.0.0 upgrade

3 participants