diff --git a/docker-compose.yml b/docker-compose.yml index 4b88aab..4354de7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,8 @@ services: POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: ${POSTGRES_DB} + ports: + - "${DB_PORT:-5432}:5432" volumes: - db_data:/var/lib/postgresql/data healthcheck: diff --git a/src/initDB.js b/src/initDB.js index 1285d7c..cbaeec6 100644 --- a/src/initDB.js +++ b/src/initDB.js @@ -2,25 +2,6 @@ const sequelize = require('./config/database'); async function initDB() { 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 }); console.log('✅ Base de datos conectada y tablas sincronizadas.');