feat: Implement database initialization with custom timestamp parsers and add priority, in_progress, due_date, parent_id, and level columns to the global_todos table.

This commit is contained in:
Michael committed 2026-03-25 11:14:56 +01:00
1 parent 56b257421c
commit 3f64e061e0
5 files changed
+133 -1

No files matched your search

+55
View File
@@ -57,7 +57,10 @@ function initDatabase() {
note_id INTEGER NOT NULL,
text TEXT NOT NULL,
completed BOOLEAN DEFAULT 0,
priority BOOLEAN DEFAULT 0,
position INTEGER DEFAULT 0,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
completed_at DATETIME,
FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE
)
`);
@@ -69,7 +72,11 @@ function initDatabase() {
user_id INTEGER NOT NULL,
text TEXT NOT NULL,
completed BOOLEAN DEFAULT 0,
priority BOOLEAN DEFAULT 0,
in_progress INTEGER DEFAULT 0,
due_date DATETIME,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
completed_at DATETIME,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
)
`);
@@ -286,6 +293,54 @@ function initDatabase() {
}
});
// Migration pour global_todos
db.all("PRAGMA table_info(global_todos)", (err, columns) => {
if (err) {
logger.error('Erreur lors de la vérification de la structure de la table global_todos:', err);
return;
}
const hasPriority = columns.some(col => col.name === 'priority');
const hasInProgress = columns.some(col => col.name === 'in_progress');
const hasDueDate = columns.some(col => col.name === 'due_date');
const hasCompletedAt = columns.some(col => col.name === 'completed_at');
if (!hasPriority) {
logger.info('Migration SQLITE: Ajout de la colonne priority à global_todos...');
db.run('ALTER TABLE global_todos ADD COLUMN priority BOOLEAN DEFAULT 0');
}
if (!hasInProgress) {
logger.info('Migration SQLITE: Ajout de la colonne in_progress à global_todos...');
db.run('ALTER TABLE global_todos ADD COLUMN in_progress INTEGER DEFAULT 0');
}
if (!hasDueDate) {
logger.info('Migration SQLITE: Ajout de la colonne due_date à global_todos...');
db.run('ALTER TABLE global_todos ADD COLUMN due_date DATETIME');
}
if (!hasCompletedAt) {
logger.info('Migration SQLITE: Ajout de la colonne completed_at à global_todos...');
db.run('ALTER TABLE global_todos ADD COLUMN completed_at DATETIME');
}
});
// Migration pour note_todos
db.all("PRAGMA table_info(note_todos)", (err, columns) => {
if (err) return;
const hasPriority = columns.some(col => col.name === 'priority');
const hasCreatedAt = columns.some(col => col.name === 'created_at');
const hasCompletedAt = columns.some(col => col.name === 'completed_at');
if (!hasPriority) {
db.run('ALTER TABLE note_todos ADD COLUMN priority BOOLEAN DEFAULT 0');
}
if (!hasCreatedAt) {
db.run('ALTER TABLE note_todos ADD COLUMN created_at DATETIME DEFAULT CURRENT_TIMESTAMP');
}
if (!hasCompletedAt) {
db.run('ALTER TABLE note_todos ADD COLUMN completed_at DATETIME');
}
});
// Migration pour calendar_events - ajouter all_day
db.all("PRAGMA table_info(calendar_events)", (err, columns) => {
if (err) {