Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
749582f
refactor(commons): extract archive helpers into prisma/lib
omargfh Aug 7, 2026
58519eb
feat(commons): add in-place legacy patch script
omargfh Aug 7, 2026
30a7d31
test(commons): add an end-to-end rehearsal for the legacy patch
omargfh Aug 7, 2026
a32fea4
fix(commons): drop a stale preview when a version is appended
omargfh Aug 7, 2026
79e6310
fix(commons): make version updates and attachment deletes safe to repeat
omargfh Aug 7, 2026
b1c65fd
fix(commons): set the file kind explicitly on migrated attachments
omargfh Aug 10, 2026
1212575
refactor(commons): share one netlogo parser between the archive scripts
omargfh Aug 10, 2026
3116ae0
chore(commons): remove the archive auto-convert script
omargfh Aug 10, 2026
aa7646d
refactor(commons): move the seed fixtures under prisma/seed
omargfh Aug 10, 2026
c86647c
refactor(commons): move the standalone maintenance script under prism…
omargfh Aug 10, 2026
29d1888
refactor(commons): group the legacy migration scripts under prisma/le…
omargfh Aug 10, 2026
1ddc37c
docs(commons): add old schema for reference
omargfh Aug 10, 2026
5bb0134
feat(commons): add collaborator provenance columns
omargfh Aug 10, 2026
7f38834
feat(commons): backfill legacy collaborators
omargfh Aug 10, 2026
3aaaedf
ci(commons): scope staging deployment to staging branch
omargfh Aug 10, 2026
08d01a7
fix(commons): report the interaction counts the import actually wrote
omargfh Aug 11, 2026
3587f8a
perf(commons): skip the unpatchable bulk tables in the diff
omargfh Aug 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test-modeling-commons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ jobs:

deploy-staging:
needs: test
if: github.ref == 'refs/heads/staging/modeling-commons'
uses: ./.github/workflows/build-and-push-modeling-commons.yml
with:
environment: modeling-commons-staging
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ GITIGNORE_*/**/*
.env.development
.env.production

apps/modeling-commons-backend/prisma/archive-output
apps/modeling-commons-backend/prisma/avatars
apps/modeling-commons-backend/prisma/legacy-migration/output
apps/modeling-commons-backend/prisma/legacy-migration/avatars
.nuxt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ src/modules/legacy-discussion/
Deliberately minimal:

- **No `domain/`.** This module has no domain logic — the data is frozen. The mapper handles the tombstone projection.
- **No `<module>.service.ts`.** No writes from the request path. The bulk importer lives in `prisma/archive.ts` (see §6) and is the only writer.
- **No `<module>.service.ts`.** No writes from the request path. The bulk importer lives in `prisma/legacy-migration/initial-import.ts` (see §6) and is the only writer.
- **No `patches/`.** Same reason.
- **One query** (`list-legacy-postings`) is enough; deep-link `get-legacy-posting` is in Open Questions.

Expand Down Expand Up @@ -184,7 +184,7 @@ Notes:
- **No POST / PATCH** anywhere. Surface-area discipline: the archive is data, not a feature.
- The list route piggybacks on `resolveModel('read')` instead of layering its own visibility logic. If you can't see the model, you can't see its archive. Anonymous viewers can read archives on public/unlisted models, same as they can read the model itself.

## 7. Importer (extends `prisma/archive.ts`)
## 7. Importer (extends `prisma/legacy-migration/initial-import.ts`)

The bulk import is a new step in the existing seed script, called from `main()` after `migrateNodes` so `modelIdMap` and `userIdMap` are in scope:

Expand Down Expand Up @@ -293,7 +293,7 @@ Idempotency:
- Re-running the seed picks up new legacy rows (none expected — legacy DB is frozen — but the script supports it). Existing rows are skipped via the `legacyId` probe in pass 1; pass 2's update is no-op-safe (same parent uuid).
- `WIPE_TARGET=true` already truncates the right cascade; add `"LegacyModelPosting"` to the truncate list in `wipeTarget`.

Report counters to add to the existing `report` object in `archive.ts`:
Report counters to add to the existing `report` object in `initial-import.ts`:

```ts
legacyPostings: {
Expand Down Expand Up @@ -371,7 +371,7 @@ Awilix auto-loads by filename. No service to register.

### Importer

- **`prisma/archive.legacy-postings.spec.ts`** (heavy; gated behind an integration flag because it touches the legacy DB)
- **`prisma/legacy-migration/legacy-postings.spec.ts`** (heavy; gated behind an integration flag because it touches the legacy DB)
- Seed a small `postings` fixture in a test legacy DB; run the import step; assert row counts, parent links, tombstone bodies, orphan-skip behavior.
- Re-run the import; assert `skipped_existing` increments and no duplicates appear.

Expand Down Expand Up @@ -400,13 +400,13 @@ Awilix auto-loads by filename. No service to register.
## 13. Sequencing

- **No dependency on `[[legacy-migration-discussion-plan]] / model-comment` landing first.** This module is independent.
- **Does depend on `prisma/archive.ts` Users/Models import** for the `userIdMap` / `modelIdMap`. Already in place — postings just get a new step downstream of those.
- **Does depend on `prisma/legacy-migration/initial-import.ts` Users/Models import** for the `userIdMap` / `modelIdMap`. Already in place — postings just get a new step downstream of those.
- Land order, if both this plan and `model-comment` are picked up: either order is fine; they don't touch each other.

## 14. References

- Legacy schema: `/Users/pas6148/Documents/netlogo/modelingcommons/db/schema.rb` (lines 240–259 — `postings` table).
- Legacy model: `/Users/pas6148/Documents/netlogo/modelingcommons/app/models/posting.rb`.
- Existing importer: `apps/modeling-commons-backend/prisma/archive.ts` (extends in §7).
- Existing importer: `apps/modeling-commons-backend/prisma/legacy-migration/initial-import.ts` (extends in §7).
- Mirror module shape: `src/modules/model-author/` (smallest existing module skeleton).
- Cross-link: [[legacy-migration-discussion-plan]] (the active comment system).
21 changes: 17 additions & 4 deletions apps/modeling-commons-backend/generated/prisma/edge.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions apps/modeling-commons-backend/generated/prisma/index-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,18 @@ exports.Prisma.ModelAuthorScalarFieldEnum = {
modelId: 'modelId',
userId: 'userId',
role: 'role',
collaboratorType: 'collaboratorType',
createdAt: 'createdAt'
};

exports.Prisma.NonMemberContributorScalarFieldEnum = {
id: 'id',
legacyId: 'legacyId',
modelId: 'modelId',
email: 'email',
name: 'name',
collaboratorType: 'collaboratorType',
addedByUserId: 'addedByUserId',
createdAt: 'createdAt'
};

Expand Down Expand Up @@ -393,6 +405,7 @@ exports.Prisma.ModelName = {
ModelAdditionalFile: 'ModelAdditionalFile',
Tag: 'Tag',
ModelAuthor: 'ModelAuthor',
NonMemberContributor: 'NonMemberContributor',
ModelPermission: 'ModelPermission',
ModelLike: 'ModelLike',
ModelInteraction: 'ModelInteraction',
Expand Down
Loading