Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Event ingestions when using a non default schema #2314

Conversation

roeeklinger
Copy link
Contributor

Context

Currently the database configuration for production looks like so:

production:
  primary:
    <<: *default
    url: <%= ENV['DATABASE_URL'] %>
    pool: <%= ENV.fetch('DATABASE_POOL', 10) %>
    prepared_statements: <%= ENV.fetch('DATABASE_PREPARED_STATEMENTS', true) %>
    schema_search_path: <%= ENV.fetch('POSTGRES_SCHEMA', 'public') %>
  events:
    <<: *default
    url: <%= ENV['DATABASE_URL'] %>
    pool: <%= ENV.fetch('DATABASE_POOL', 10) %>
    prepared_statements: <%= ENV.fetch('DATABASE_PREPARED_STATEMENTS', true) %>
    database_tasks: false

As you can see, schema_search_path is configured for primary but missing for events. This means that migrations and all the main logic will run on POSTGRES_SCHEMA if configured, but events will still look for the tables in the public schema, which will not exist, causing an error and rendering Lago features such as events ingestion completely unusable.

This PR simply also adds the same schema_search_path directive to the events config, making them match and fixing the issue. I have extensively tested this code on my self deployed Lago over the past week.

Description

Make the schema_search_path for primary and events match and be identical so they can find each other's data.

@roeeklinger
Copy link
Contributor Author

Thanks for the review and approval! @julienbourdeau

What are the next steps I should take to help get this merged? I can't find an guidelines regarding that

@nudded nudded merged commit dcba21c into getlago:main Aug 1, 2024
3 checks passed
@nudded
Copy link
Contributor

nudded commented Aug 1, 2024

Thanks @roeeklinger!

abdussamadbello pushed a commit to abdussamadbello/lago-api that referenced this pull request Aug 8, 2024
## Context

Currently the database configuration for production looks like so:
```
production:
  primary:
    <<: *default
    url: <%= ENV['DATABASE_URL'] %>
    pool: <%= ENV.fetch('DATABASE_POOL', 10) %>
    prepared_statements: <%= ENV.fetch('DATABASE_PREPARED_STATEMENTS', true) %>
    schema_search_path: <%= ENV.fetch('POSTGRES_SCHEMA', 'public') %>
  events:
    <<: *default
    url: <%= ENV['DATABASE_URL'] %>
    pool: <%= ENV.fetch('DATABASE_POOL', 10) %>
    prepared_statements: <%= ENV.fetch('DATABASE_PREPARED_STATEMENTS', true) %>
    database_tasks: false
```

As you can see, schema_search_path is configured for `primary` but
missing for `events`. This means that migrations and all the main logic
will run on POSTGRES_SCHEMA if configured, but events will still look
for the tables in the `public` schema, which will not exist, causing an
error and rendering Lago features such as events ingestion completely
unusable.

This PR simply also adds the same `schema_search_path` directive to the
events config, making them match and fixing the issue. I have
extensively tested this code on my self deployed Lago over the past
week.

## Description

Make the schema_search_path for `primary` and `events` match and be
identical so they can find each other's data.
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