This commit is contained in:
+2
-5
@@ -2,11 +2,8 @@ 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.');
|
||||||
|
|
||||||
// console.log('ℹ️ Creación de usuario por defecto desactivada.');
|
// console.log('ℹ️ Creación de usuario por defecto desactivada.');
|
||||||
|
|||||||
@@ -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: {
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user