diff --git a/scripts/docker/entrypoint-allinone.sh b/scripts/docker/entrypoint-allinone.sh index b4eb85a..0a9425c 100644 --- a/scripts/docker/entrypoint-allinone.sh +++ b/scripts/docker/entrypoint-allinone.sh @@ -122,10 +122,11 @@ if [ ! -f /data/postgres/PG_VERSION ]; then ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON SEQUENCES TO ${ELECTRIC_DB_USER}; -- Create the publication for Electric SQL (if not exists) + -- Must use FOR ALL TABLES so Electric can sync all tables DO \\\$\\\$ BEGIN IF NOT EXISTS (SELECT FROM pg_publication WHERE pubname = 'electric_publication_default') THEN - CREATE PUBLICATION electric_publication_default; + CREATE PUBLICATION electric_publication_default FOR ALL TABLES; END IF; END \\\$\\\$; @@ -180,6 +181,12 @@ run_migrations() { cd /app/backend alembic upgrade head || echo "⚠️ Migrations may have already been applied" + # Recreate Electric publication AFTER migrations so all tables are included + # FOR ALL TABLES only captures tables that exist at creation time + echo "📡 Refreshing Electric SQL publication..." + su - postgres -c "psql -d ${POSTGRES_DB:-financegpt} -c \"DROP PUBLICATION IF EXISTS electric_publication_default; CREATE PUBLICATION electric_publication_default FOR ALL TABLES;\"" + echo "✅ Electric SQL publication refreshed with all tables" + # Stop temporary services redis-cli shutdown || true su - postgres -c "/usr/lib/postgresql/14/bin/pg_ctl -D /data/postgres stop"