Skip to content

Conversation

@rikukissa
Copy link
Member

@rikukissa rikukissa commented Sep 25, 2025

Description

Clearly describe what has been changed. Include relevant context or background.
Explain how the issue was fixed (if applicable) and the root cause.

Link this pull request to the GitHub issue (and optionally name the branch ocrvs-<issue #>)

Checklist

  • I have linked the correct Github issue under "Development"
  • I have tested the changes locally, and written appropriate tests
  • I have tested beyond the happy path (e.g. edge cases, failure paths)
  • I have updated the changelog with this change (if applicable)
  • I have updated the GitHub issue status accordingly

@github-actions
Copy link
Contributor

Oops! Looks like you forgot to update the changelog. When updating CHANGELOG.md, please consider the following:

  • Changelog is read by country implementors who might not always be familiar with all technical details of OpenCRVS. Keep language high-level, user friendly and avoid technical references to internals.
  • Answer "What's new?", "Why was the change made?" and "Why should I care?" for each change.
  • If it's a breaking change, include a migration guide answering "What do I need to do to upgrade?".

POSTGRES_DB="events"
EVENTS_MIGRATOR_ROLE="events_migrator"
EVENTS_APP_ROLE="events_app"
ANALYTICS_POSTGRES_USER=${ANALYTICS_POSTGRES_USER:-"events_analytics"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the role of this user in deployed environments or even locally? I just see it being dropped if it exists

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This user should be the one Metabase uses to access the analytics database. In real deployments, you'd have two different databases completely with a different set of creds

@Zangetsu101
Copy link
Contributor

Zangetsu101 commented Oct 8, 2025

I got the following error after merging develop and running the command:

🧹 Clearing all development data...
❌ Cannot connect to PostgreSQL at localhost:5432
   Make sure PostgreSQL is running and credentials are correct.

And postgres is up and running when I ran this

@rikukissa
Copy link
Member Author

I got the following error after merging develop and running the command:

🧹 Clearing all development data...
❌ Cannot connect to PostgreSQL at localhost:5432
   Make sure PostgreSQL is running and credentials are correct.

And postgres is up and running when I ran this

My output right now:

yarn run v1.22.18
$ bash infrastructure/clear-all-data-dev.sh && yarn setup-analytics
🧹 Clearing all development data...
🗑️  Clearing PostgreSQL analytics schema...
WARNING:  database "events" has a collation version mismatch
DETAIL:  The database was created using collation version 2.36, but the operating system provides version 2.41.
HINT:  Rebuild all objects in this database that use the default collation and run ALTER DATABASE events REFRESH COLLATION VERSION, or build PostgreSQL with the right library version.
NOTICE:  drop cascades to 4 other objects
DETAIL:  drop cascades to table analytics.locations
drop cascades to table analytics.event_actions
drop cascades to table analytics.location_levels
drop cascades to table analytics.location_statistics
DROP SCHEMA
CREATE SCHEMA
ERROR:  role "events_analytics" cannot be dropped because some objects depend on it
DETAIL:  privileges for database events
⚠️  Analytics schema may not exist yet
✅ PostgreSQL analytics data cleared

🎉 All development data cleared successfully!

$ docker exec -i -e POSTGRES_HOST=localhost -e POSTGRES_PORT=5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e ANALYTICS_POSTGRES_USER=events_analytics -e ANALYTICS_POSTGRES_PASSWORD=analytics_password postgres bash -s < ./infrastructure/postgres/setup-analytics.sh
Waiting for PostgreSQL to be ready at localhost:5432...
WARNING:  database "postgres" has a collation version mismatch
DETAIL:  The database was created using collation version 2.36, but the operating system provides version 2.41.
HINT:  Rebuild all objects in this database that use the default collation and run ALTER DATABASE postgres REFRESH COLLATION VERSION, or build PostgreSQL with the right library version.
DO
WARNING:  database "events" has a collation version mismatch
DETAIL:  The database was created using collation version 2.36, but the operating system provides version 2.41.
HINT:  Rebuild all objects in this database that use the default collation and run ALTER DATABASE events REFRESH COLLATION VERSION, or build PostgreSQL with the right library version.
NOTICE:  schema "analytics" already exists, skipping
CREATE SCHEMA
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE TABLE
CREATE TABLE
GRANT
GRANT
✅ Analytics schema initialized for database 'events'
✨  Done in 0.78s.

-e POSTGRES_DB="${POSTGRES_DB}" \
-e EVENTS_MIGRATOR_ROLE="${EVENTS_MIGRATOR_ROLE}" \
-e EVENTS_APP_ROLE="${EVENTS_APP_ROLE}" \
-e ANALYTICS_POSTGRES_USER="${ANALYTICS_POSTGRES_USER}" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The e2e repo needs any changes regarding this? I mean this will be different for each feature environment right?

@rikukissa rikukissa merged commit 74c59b9 into develop Oct 16, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants