feat: add active column to groups table with default true

main
borja (aider) 3 months ago
parent c9c990b815
commit 1ef8ac55c7

@ -34,7 +34,8 @@ export function initializeDatabase() {
id TEXT PRIMARY KEY,
community_id TEXT NOT NULL,
name TEXT,
last_verified TIMESTAMP DEFAULT CURRENT_TIMESTAMP
last_verified TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
active BOOLEAN DEFAULT TRUE
);
`);
}

@ -31,12 +31,13 @@ describe('Database', () => {
expect(tasksColumns).toContain('description');
expect(tasksColumns).toContain('due_date');
// Verify groups table has last_verified column
// Verify groups table columns
const groupsColumns = db
.query("PRAGMA table_info(groups)")
.all()
.map((c: any) => c.name);
expect(groupsColumns).toContain('last_verified');
expect(groupsColumns).toContain('active');
// Verify foreign key constraint
const fkInfo = db
@ -46,5 +47,13 @@ describe('Database', () => {
expect(fkInfo[0].from).toBe('task_id');
expect(fkInfo[0].to).toBe('id');
expect(fkInfo[0].table).toBe('tasks');
// Verify default active status
db.exec(`
INSERT INTO groups (id, community_id, name)
VALUES ('test-group', 'test-community', 'Test Group')
`);
const group = db.query("SELECT active FROM groups WHERE id = 'test-group'").get();
expect(group.active).toBe(1); // SQLite stores TRUE as 1
});
});

Loading…
Cancel
Save