/** * Personal Notes — lightweight per-user scratchpad living under * Clinical Tools. Distinct from user_memories (which feed AI * prompts as style hints / templates): personal_notes are pure * clinician notes, never injected into an AI call. Title + rich- * text body, encrypted at rest like memories so row dumps are * useless without the app crypto key. */ exports.up = (pgm) => { pgm.createTable('personal_notes', { id: { type: 'serial', primaryKey: true }, user_id: { type: 'integer', notNull: true, references: 'users(id)', onDelete: 'CASCADE' }, title: { type: 'text', notNull: true }, body: { type: 'text', notNull: true, default: '' }, created_at: { type: 'timestamptz', notNull: true, default: pgm.func('NOW()') }, updated_at: { type: 'timestamptz', notNull: true, default: pgm.func('NOW()') }, }); pgm.createIndex('personal_notes', 'user_id'); pgm.createIndex('personal_notes', ['user_id', 'updated_at']); }; exports.down = (pgm) => { pgm.dropTable('personal_notes'); };