Ejemplo con la inspección 250:
Guardado en BD: 2025-12-08 19:11:30+00 (hora de Canarias) Mostrado en tu cliente: 2025-12-08 16:11:30-03 (convertido a Paraguay, 3 horas menos) Ambas representan el MISMO momento en el tiempo, solo que en zonas horarias diferentes. 🌍 Resumen del Sistema Componente Zona Horaria Estado PostgreSQL (almacenamiento) +00 Atlantic/Canary ✅ CORRECTO Backend FastAPI Atlantic/Canary ✅ CORRECTO Frontend (usuario) Local del navegador ✅ CORRECTO (convierte automáticamente) Tu cliente PostgreSQL -0300 Paraguay ℹ️ Solo afecta cómo VES las fechas 💡 Conclusión
This commit is contained in:
40
apply-timezone.bat
Normal file
40
apply-timezone.bat
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
@echo off
|
||||||
|
echo ====================================
|
||||||
|
echo Aplicando configuracion de timezone
|
||||||
|
echo ====================================
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo 1. Copiando script de migracion...
|
||||||
|
docker cp migrations/force_timezone_all_sessions.sql checklist-db:/tmp/
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo 2. Ejecutando migracion en checklist_db...
|
||||||
|
docker exec checklist-db psql -U checklist_user -d checklist_db -f /tmp/force_timezone_all_sessions.sql
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo 3. Ejecutando migracion en syntria_db (si existe)...
|
||||||
|
docker exec checklist-db psql -U checklist_user -d postgres -c "SELECT 1 FROM pg_database WHERE datname = 'syntria_db'" | find "1" >nul
|
||||||
|
if %ERRORLEVEL% equ 0 (
|
||||||
|
docker exec checklist-db psql -U syntria_user -d syntria_db -f /tmp/force_timezone_all_sessions.sql
|
||||||
|
echo Migración aplicada a syntria_db
|
||||||
|
) else (
|
||||||
|
echo syntria_db no existe, omitiendo...
|
||||||
|
)
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo 4. Recargando configuracion de PostgreSQL...
|
||||||
|
docker exec checklist-db psql -U checklist_user -d checklist_db -c "SELECT pg_reload_conf();"
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo 5. Verificando timezone...
|
||||||
|
docker exec checklist-db psql -U checklist_user -d checklist_db -c "SHOW timezone;"
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ====================================
|
||||||
|
echo Completado!
|
||||||
|
echo ====================================
|
||||||
|
echo.
|
||||||
|
echo IMPORTANTE: Desconecta y reconecta tu cliente PostgreSQL
|
||||||
|
echo para que aplique la nueva zona horaria.
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
39
apply-timezone.sh
Normal file
39
apply-timezone.sh
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "===================================="
|
||||||
|
echo "Aplicando configuración de timezone"
|
||||||
|
echo "===================================="
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "1. Copiando script de migración..."
|
||||||
|
docker cp migrations/force_timezone_all_sessions.sql checklist-db:/tmp/
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "2. Ejecutando migración en checklist_db..."
|
||||||
|
docker exec checklist-db psql -U checklist_user -d checklist_db -f /tmp/force_timezone_all_sessions.sql
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "3. Ejecutando migración en syntria_db (si existe)..."
|
||||||
|
if docker exec checklist-db psql -U checklist_user -d postgres -tc "SELECT 1 FROM pg_database WHERE datname = 'syntria_db'" | grep -q 1; then
|
||||||
|
docker exec checklist-db psql -U syntria_user -d syntria_db -f /tmp/force_timezone_all_sessions.sql
|
||||||
|
echo "Migración aplicada a syntria_db"
|
||||||
|
else
|
||||||
|
echo "syntria_db no existe, omitiendo..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "4. Recargando configuración de PostgreSQL..."
|
||||||
|
docker exec checklist-db psql -U checklist_user -d checklist_db -c "SELECT pg_reload_conf();"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "5. Verificando timezone..."
|
||||||
|
docker exec checklist-db psql -U checklist_user -d checklist_db -c "SHOW timezone;"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "===================================="
|
||||||
|
echo "Completado!"
|
||||||
|
echo "===================================="
|
||||||
|
echo ""
|
||||||
|
echo "IMPORTANTE: Desconecta y reconecta tu cliente PostgreSQL"
|
||||||
|
echo "para que aplique la nueva zona horaria."
|
||||||
|
echo ""
|
||||||
@@ -13,6 +13,8 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
- ./init-db.sh:/docker-entrypoint-initdb.d/init-db.sh
|
- ./init-db.sh:/docker-entrypoint-initdb.d/init-db.sh
|
||||||
|
- ./postgres-custom.conf:/etc/postgresql/postgresql.conf
|
||||||
|
command: postgres -c config_file=/etc/postgresql/postgresql.conf
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-checklist_user} -d ${POSTGRES_DB:-checklist_db}"]
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-checklist_user} -d ${POSTGRES_DB:-checklist_db}"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
|
|||||||
@@ -2,12 +2,19 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
||||||
|
-- Configurar zona horaria Atlantic/Canary
|
||||||
|
ALTER DATABASE "$POSTGRES_DB" SET timezone TO 'Atlantic/Canary';
|
||||||
|
ALTER ROLE "$POSTGRES_USER" SET timezone TO 'Atlantic/Canary';
|
||||||
|
|
||||||
-- Verificar que la base de datos existe
|
-- Verificar que la base de datos existe
|
||||||
SELECT 'Database is ready!' as status;
|
SELECT 'Database is ready!' as status;
|
||||||
|
|
||||||
-- Crear extensiones si son necesarias
|
-- Crear extensiones si son necesarias
|
||||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||||
|
|
||||||
|
-- Mostrar zona horaria configurada
|
||||||
|
SHOW timezone;
|
||||||
EOSQL
|
EOSQL
|
||||||
|
|
||||||
echo "Database initialization completed successfully!"
|
echo "Database initialization completed successfully with timezone: Atlantic/Canary"
|
||||||
|
|
||||||
|
|||||||
17
migrations/force_timezone_all_sessions.sql
Normal file
17
migrations/force_timezone_all_sessions.sql
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
-- Forzar zona horaria Atlantic/Canary en TODAS las sesiones
|
||||||
|
-- Esto anula cualquier configuración del cliente
|
||||||
|
|
||||||
|
-- 1. Establecer timezone por defecto para la base de datos
|
||||||
|
ALTER DATABASE checklist_db SET timezone TO 'Atlantic/Canary';
|
||||||
|
ALTER DATABASE syntria_db SET timezone TO 'Atlantic/Canary';
|
||||||
|
|
||||||
|
-- 2. Establecer timezone por defecto para todos los usuarios
|
||||||
|
ALTER ROLE checklist_user SET timezone TO 'Atlantic/Canary';
|
||||||
|
ALTER ROLE syntria_user SET timezone TO 'Atlantic/Canary';
|
||||||
|
ALTER ROLE postgres SET timezone TO 'Atlantic/Canary';
|
||||||
|
|
||||||
|
-- 3. Verificar configuración actual
|
||||||
|
SHOW timezone;
|
||||||
|
|
||||||
|
-- 4. Para aplicar los cambios, desconectar y reconectar
|
||||||
|
-- O forzar: SELECT pg_reload_conf();
|
||||||
24
postgres-custom.conf
Normal file
24
postgres-custom.conf
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Configuración de PostgreSQL para Ayutec
|
||||||
|
# Zona horaria: Atlantic/Canary (Islas Canarias, España)
|
||||||
|
|
||||||
|
# ZONA HORARIA
|
||||||
|
timezone = 'Atlantic/Canary'
|
||||||
|
log_timezone = 'Atlantic/Canary'
|
||||||
|
|
||||||
|
# LOCALE (opcional - para formato de fechas en español)
|
||||||
|
lc_messages = 'es_ES.UTF-8'
|
||||||
|
lc_monetary = 'es_ES.UTF-8'
|
||||||
|
lc_numeric = 'es_ES.UTF-8'
|
||||||
|
lc_time = 'es_ES.UTF-8'
|
||||||
|
|
||||||
|
# CONEXIONES
|
||||||
|
max_connections = 100
|
||||||
|
shared_buffers = 256MB
|
||||||
|
|
||||||
|
# LOGGING
|
||||||
|
logging_collector = on
|
||||||
|
log_directory = 'pg_log'
|
||||||
|
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
|
||||||
|
log_statement = 'mod' # Registrar INSERT, UPDATE, DELETE
|
||||||
|
log_duration = on
|
||||||
|
log_line_prefix = '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h '
|
||||||
Reference in New Issue
Block a user