Skip to content

Commit 181c54c

Browse files
committed
Remove unused database mutation helpers.
1 parent 46059e9 commit 181c54c

2 files changed

Lines changed: 3 additions & 17 deletions

File tree

‎platform/packages/api/src/db.ts‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2930,10 +2930,6 @@ export async function promoteEmailDestinationWithOwnerAudit(
29302930

29312931
// --- Deletion ---
29322932

2933-
export async function deleteProject(db: Db, id: string): Promise<void> {
2934-
await db.delete(projects).where(eq(projects.id, id));
2935-
}
2936-
29372933
export type ProjectCleanupJobInput = typeof projectCleanupJobs.$inferInsert;
29382934

29392935
export function cleanupJobsForResource(
@@ -3239,17 +3235,6 @@ export async function unsuspendUser(db: Db, id: string): Promise<void> {
32393235
await db.update(users).set({ suspended_reason: null }).where(eq(users.id, id));
32403236
}
32413237

3242-
export async function updateUserRole(db: Db, id: string, role: 'user' | 'admin'): Promise<void> {
3243-
const update = async (target: Db) => {
3244-
await target.update(users).set({ role }).where(eq(users.id, id));
3245-
};
3246-
if (role === 'user') {
3247-
await withAdminRemovalGuard(db, id, update);
3248-
} else {
3249-
await update(db);
3250-
}
3251-
}
3252-
32533238
export async function deleteUser(db: Db, id: string): Promise<ReadonlyArray<TerminatedBuild>> {
32543239
return withAdminRemovalGuard(db, id, async (tx) => {
32553240
const cancelledBuilds: Array<TerminatedBuild> = [];

‎platform/packages/api/test/integration/operator-last-admin.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
LastAdminError,
1717
prepareUserRemoval,
1818
suspendUser,
19-
updateUserRole,
2019
} from '../../src/db.ts';
2120
import { app } from '../../src/index.ts';
2221
import { resources, users } from '../../src/schema.ts';
@@ -124,7 +123,9 @@ describe('last active administrator protection', () => {
124123

125124
test('guards low-level deletion, demotion, and manual suspension but permits usage enforcement', async () => {
126125
await expect(deleteUser(env.db, admin.id)).rejects.toBeInstanceOf(LastAdminError);
127-
await expect(updateUserRole(env.db, admin.id, 'user')).rejects.toBeInstanceOf(LastAdminError);
126+
await expect(prepareUserRemoval(env.db, admin.id, { kind: 'delete' })).rejects.toBeInstanceOf(
127+
LastAdminError,
128+
);
128129
await expect(suspendUser(env.db, admin.id, 'admin_suspended')).rejects.toBeInstanceOf(
129130
LastAdminError,
130131
);

0 commit comments

Comments
 (0)