This commit is contained in:
+1
-4
@@ -2,10 +2,7 @@ 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.');
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ const Category = sequelize.define('Category', {
|
||||
allowNull: false
|
||||
},
|
||||
colorValue: {
|
||||
type: DataTypes.INTEGER,
|
||||
type: DataTypes.BIGINT,
|
||||
allowNull: true
|
||||
},
|
||||
iconCodePoint: {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user