Remove username to email migration logic from initDB function
Despliegue Automático / desplegar (push) Successful in 53s

This commit is contained in:
2026-07-28 18:44:02 +02:00
parent 674d8e9393
commit d73e1b2ddd
2 changed files with 2 additions and 19 deletions
+2
View File
@@ -9,6 +9,8 @@ services:
POSTGRES_USER: ${POSTGRES_USER} POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB} POSTGRES_DB: ${POSTGRES_DB}
ports:
- "${DB_PORT:-5432}:5432"
volumes: volumes:
- db_data:/var/lib/postgresql/data - db_data:/var/lib/postgresql/data
healthcheck: healthcheck:
-19
View File
@@ -2,25 +2,6 @@ const sequelize = require('./config/database');
async function initDB() { async function initDB() {
try { try {
const queryInterface = sequelize.getQueryInterface();
const tableName = 'Users';
if (await queryInterface.tableExists(tableName)) {
const tableDescription = await queryInterface.describeTable(tableName);
if (tableDescription.username && !tableDescription.email) {
await queryInterface.renameColumn(tableName, 'username', 'email');
}
if (tableDescription.username && tableDescription.email) {
await sequelize.query(
`UPDATE "${tableName}"
SET "email" = COALESCE("email", "username")
WHERE "email" IS NULL AND "username" IS NOT NULL;`
);
}
}
await sequelize.sync({ alter: true }); await sequelize.sync({ alter: true });
console.log('✅ Base de datos conectada y tablas sincronizadas.'); console.log('✅ Base de datos conectada y tablas sincronizadas.');