From 55d47d0a30b4fe1500b0871561f6957e248e9fb3 Mon Sep 17 00:00:00 2001 From: HugoXK Date: Thu, 5 Nov 2026 17:40:20 +0800 Subject: [PATCH] fix: migrate the private model flag on users The allow_private_models column was added to the repos migration list instead of users, so existing databases never got the user column. Move the migration to the users additions and assert the flag persists. --- src/db.ts | 2 +- test/db.test.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/db.ts b/src/db.ts index f5b71f0..956cde7 100644 --- a/src/db.ts +++ b/src/db.ts @@ -728,6 +728,7 @@ export class Store { ['email_job_updates', 'INTEGER NOT NULL DEFAULT 1'], ['email_daily_digest', 'INTEGER NOT NULL DEFAULT 1'], ['notify_email', 'TEXT'], + ['allow_private_models', 'INTEGER NOT NULL DEFAULT 0'], ['github_token_scopes', 'TEXT'], ] for (const [name, type] of additions) { @@ -747,7 +748,6 @@ export class Store { ['allow_paths', "TEXT NOT NULL DEFAULT ''"], ['deny_paths', "TEXT NOT NULL DEFAULT ''"], ['merge_method', "TEXT NOT NULL DEFAULT 'squash'"], - ['allow_private_models', 'INTEGER NOT NULL DEFAULT 0'], ['require_protection', 'INTEGER NOT NULL DEFAULT 1'], ['stage_mode', "TEXT NOT NULL DEFAULT 'off'"], ['models_dirty', 'INTEGER NOT NULL DEFAULT 0'], diff --git a/test/db.test.ts b/test/db.test.ts index fe65889..040f428 100644 --- a/test/db.test.ts +++ b/test/db.test.ts @@ -371,3 +371,15 @@ test('repository bot model assignments persist and are cleaned with the selectio store.close() } }) + +test('the per-user private model permission persists', () => { + const store = new Store(':memory:') + try { + const user = makeUser(store, { login: 'private-permission-user', status: 'approved' }) + assert.equal(store.userById(user.id)?.allow_private_models, 0) + store.setUserAllowPrivateModels(user.id, true) + assert.equal(store.userById(user.id)?.allow_private_models, 1) + } finally { + store.close() + } +})