Skip to content

Commit f7144f6

Browse files
authored
Stop dual-writing Future of AI registrations (#2673)
* Stop dual-writing Future of AI registrations * Remove path-dependent comment
1 parent aa722b4 commit f7144f6

3 files changed

Lines changed: 4 additions & 30 deletions

File tree

apps/website/src/server/routers/certificates.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ describe('issueFoaiCertificateIfComplete', () => {
339339
});
340340
};
341341

342-
test('issues the certificate on the self-serve row and mirrors it to legacy', async () => {
342+
test('issues the certificate on the self-serve row only', async () => {
343343
await testDb.insert(selfServeCourseRegistrationTable, {
344344
id: 'ss-1', email: 'test@example.com', courseId: FOAI_COURSE_ID, createdAt: '2026-01-01T00:00:00.000Z',
345345
});
@@ -355,8 +355,7 @@ describe('issueFoaiCertificateIfComplete', () => {
355355
expect(selfServe?.certificateId).toBe('ss-1');
356356

357357
const legacy = await testDb.get(courseRegistrationTable, { id: 'reg-foai' });
358-
expect(legacy.certificateId).toBe('ss-1');
359-
expect(legacy.certificateCreatedAt).toBe(selfServe?.certificateCreatedAt);
358+
expect(legacy.certificateId).toBeNull();
360359
});
361360

362361
test('does nothing when no self-serve row exists', async () => {

apps/website/src/server/routers/certificates.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,6 @@ export async function issueFoaiCertificateIfComplete(email: string): Promise<boo
6262

6363
await db.update(selfServeCourseRegistrationTable, { id: selfServeRegistration.id, certificateId, certificateCreatedAt });
6464

65-
// Keep the legacy row in sync until it's deleted at the end of the migration (#2526)
66-
const legacyRegistration = await db.getFirst(courseRegistrationTable, {
67-
filter: { email, courseId: FOAI_COURSE_ID, decision: 'Accept' },
68-
});
69-
if (legacyRegistration && !legacyRegistration.certificateId) {
70-
await db.update(courseRegistrationTable, { id: legacyRegistration.id, certificateId, certificateCreatedAt });
71-
}
72-
7365
return true;
7466
}
7567

apps/website/src/server/routers/self-serve-course-registrations.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
applicationsCourseTable, COURSE_ROLE, courseRegistrationTable, selfServeCourseRegistrationTable, userTable,
2+
applicationsCourseTable, selfServeCourseRegistrationTable, userTable,
33
} from '@bluedot/db';
44
import z from 'zod';
55
import { TRPCError } from '@trpc/server';
@@ -40,29 +40,12 @@ export const ensureSelfServeRegistrationExistsProcedure = protectedProcedure
4040
throw new TRPCError({ code: 'PRECONDITION_FAILED', message: 'User record not available yet' });
4141
}
4242

43-
const selfServeRegistration = await db.insert(selfServeCourseRegistrationTable, {
43+
return db.insert(selfServeCourseRegistrationTable, {
4444
userId: user.id,
4545
courseApplicationsBaseId: applicationsCourse.id,
4646
source: source ?? null,
4747
createdAt: new Date().toISOString(),
4848
});
49-
50-
// Keep dual-writing the legacy row until the migration to the self-serve table (#2526)
51-
// is fully complete
52-
const existingLegacy = await db.getFirst(courseRegistrationTable, {
53-
filter: { email: ctx.auth.email, courseId, decision: 'Accept' },
54-
});
55-
if (!existingLegacy) {
56-
await db.insert(courseRegistrationTable, {
57-
email: ctx.auth.email,
58-
courseApplicationsBaseId: applicationsCourse.id,
59-
role: COURSE_ROLE.PARTICIPANT,
60-
decision: 'Accept',
61-
source: source ?? null,
62-
});
63-
}
64-
65-
return selfServeRegistration;
6649
});
6750

6851
export const selfServeCourseRegistrationsRouter = router({

0 commit comments

Comments
 (0)