From ded4c8fc03d9c900a05ec6f6cfe2ae1da90e0dbb Mon Sep 17 00:00:00 2001 From: Marcos Date: Mon, 17 Aug 2026 18:39:33 +0200 Subject: [PATCH] cambiar campo color categoria --- src/initDB.js | 7 ++----- src/models/Category.js | 2 +- src/services/syncService.js | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/initDB.js b/src/initDB.js index c2b7fb1..ac3f822 100644 --- a/src/initDB.js +++ b/src/initDB.js @@ -2,11 +2,8 @@ const sequelize = require('./config/database'); async function initDB() { try { - // IMPORTANTISIMO: En producción, no uses force: true porque borrará todas las tablas y datos. Solo úsalo en desarrollo. - await sequelize.sync({ force: true }); // Borra y recrea las tablas en cada inicio (útil para desarrollo, no recomendado en producción) - // - - + await sequelize.sync({ alter: true }); + console.log('✅ Base de datos conectada y tablas sincronizadas.'); // console.log('ℹ️ Creación de usuario por defecto desactivada.'); diff --git a/src/models/Category.js b/src/models/Category.js index 0dec885..5d6a195 100644 --- a/src/models/Category.js +++ b/src/models/Category.js @@ -13,7 +13,7 @@ const Category = sequelize.define('Category', { allowNull: false }, colorValue: { - type: DataTypes.INTEGER, + type: DataTypes.BIGINT, allowNull: true }, iconCodePoint: { diff --git a/src/services/syncService.js b/src/services/syncService.js index a25ee20..b0d0108 100644 --- a/src/services/syncService.js +++ b/src/services/syncService.js @@ -14,7 +14,7 @@ const isValidDate = (value) => { const normalizeCategory = (category) => ({ id: category.id, encrypted_name: category.encrypted_name, - colorValue: category.colorValue ?? null, + colorValue: category.colorValue ? parseInt(category.colorValue, 10) : null, iconCodePoint: category.iconCodePoint ?? null, delete: Boolean(category.delete), serverVersion: category.serverVersion || 1, @@ -24,7 +24,6 @@ const normalizeCategory = (category) => ({ const normalizeNote = (note) => ({ id: note.id, - // 👇 Convertimos la relación de Sequelize en un array simple de IDs de categorías categoryIds: note.Categories ? note.Categories.map(c => c.id) : [], title: note.title, body: note.body,