feat(db): drop users.consentGiven/consentAt (ADR-0014 step 8)
Backfills consent_given=1 rows into user_consents as data:core before dropping the legacy columns. auth.ts now writes user_consents on signup; POST /consent writes user_consents; admin/user routes cleaned of the old fields. Migration is idempotent — DROP COLUMN is wrapped in try/catch so it no-ops on fresh DBs that never had the columns. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -72,7 +72,6 @@ beforeAll(async () => {
|
||||
name: 'Alice',
|
||||
image: null,
|
||||
role: 'user',
|
||||
consentGiven: false,
|
||||
tone: 'direct',
|
||||
tipKindsJson: JSON.stringify(['task', 'advice']),
|
||||
createdAt: NOW,
|
||||
@@ -90,13 +89,6 @@ describe('GET /api/profile', () => {
|
||||
expect(body.contexts).toEqual([]);
|
||||
});
|
||||
|
||||
it('surfaces legacy consentGiven as data:core when no consent row exists', async () => {
|
||||
await testDb.update(users).set({ consentGiven: true, consentAt: NOW });
|
||||
const res = await c('GET', '/api/profile');
|
||||
expect((res.body as any).consents['data:core']).toMatchObject({ revokedAt: null });
|
||||
await testDb.update(users).set({ consentGiven: false });
|
||||
});
|
||||
|
||||
it('includes prefs grouped by scope', async () => {
|
||||
await testDb.insert(userPreferences).values([
|
||||
{ userId: 'user-1', scope: 'orchestrator', key: 'quietHours', valueJson: '"22:00-07:00"', source: 'user', updatedAt: NOW },
|
||||
|
||||
Reference in New Issue
Block a user