cambiar campo color categoria
Despliegue Automático / desplegar (push) Successful in 1m17s

This commit is contained in:
2026-08-17 18:39:33 +02:00
parent e0de5c92b5
commit ded4c8fc03
3 changed files with 4 additions and 8 deletions
+1 -4
View File
@@ -2,10 +2,7 @@ const sequelize = require('./config/database');
async function initDB() { async function initDB() {
try { try {
// IMPORTANTISIMO: En producción, no uses force: true porque borrará todas las tablas y datos. Solo úsalo en desarrollo. await sequelize.sync({ alter: true });
await sequelize.sync({ force: true }); // Borra y recrea las tablas en cada inicio (útil para desarrollo, no recomendado en producción)
//
console.log('✅ Base de datos conectada y tablas sincronizadas.'); console.log('✅ Base de datos conectada y tablas sincronizadas.');
+1 -1
View File
@@ -13,7 +13,7 @@ const Category = sequelize.define('Category', {
allowNull: false allowNull: false
}, },
colorValue: { colorValue: {
type: DataTypes.INTEGER, type: DataTypes.BIGINT,
allowNull: true allowNull: true
}, },
iconCodePoint: { iconCodePoint: {
+1 -2
View File
@@ -14,7 +14,7 @@ const isValidDate = (value) => {
const normalizeCategory = (category) => ({ const normalizeCategory = (category) => ({
id: category.id, id: category.id,
encrypted_name: category.encrypted_name, encrypted_name: category.encrypted_name,
colorValue: category.colorValue ?? null, colorValue: category.colorValue ? parseInt(category.colorValue, 10) : null,
iconCodePoint: category.iconCodePoint ?? null, iconCodePoint: category.iconCodePoint ?? null,
delete: Boolean(category.delete), delete: Boolean(category.delete),
serverVersion: category.serverVersion || 1, serverVersion: category.serverVersion || 1,
@@ -24,7 +24,6 @@ const normalizeCategory = (category) => ({
const normalizeNote = (note) => ({ const normalizeNote = (note) => ({
id: note.id, 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) : [], categoryIds: note.Categories ? note.Categories.map(c => c.id) : [],
title: note.title, title: note.title,
body: note.body, body: note.body,