godcrm/backend/scripts/add-last-read-at.js
GOD CRM Release f89e074dd1
Some checks failed
CI / Lint / Typecheck / Test / Build (push) Has been cancelled
CI / PostgreSQL Integration Tests (push) Has been cancelled
GOD CRM — public scrubbed snapshot
Governed substrate for autonomous agents: scoped identity (passports),
audited actions, MCP workspace. Infra IPs and secrets redacted for public release.
2026-08-10 04:01:45 +03:00

36 lines
982 B
JavaScript

/**
* Migration: Add last_read_at column to conversation_participants
* For tracking unread messages
*/
import { dbRun } from '../database/connection.js';
import { isPostgres } from '../database/connection.js';
async function migrate() {
console.log('Adding last_read_at column to conversation_participants...');
try {
if (isPostgres()) {
await dbRun(`
ALTER TABLE conversation_participants
ADD COLUMN IF NOT EXISTS last_read_at TIMESTAMP
`);
} else {
// SQLite: check if column exists first
try {
await dbRun(`ALTER TABLE conversation_participants ADD COLUMN last_read_at TEXT`);
} catch (e) {
if (!e.message.includes('duplicate column')) {
throw e;
}
console.log('Column already exists');
}
}
console.log('✅ Migration complete');
process.exit(0);
} catch (error) {
console.error('Migration error:', error);
process.exit(1);
}
}
migrate();