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: add migration and postgres provider #7089

Merged
merged 20 commits into from
Feb 12, 2025
Merged

fix: add migration and postgres provider #7089

merged 20 commits into from
Feb 12, 2025

Conversation

nityanandagohain
Copy link
Member

@nityanandagohain nityanandagohain commented Feb 11, 2025

fixes https://github.com/SigNoz/platform-pod/issues/453

follow up of #7055

This makes sure that the migrations run on postgres.
Will rebase on the other pr is merged.

The API's work as expected after this change and no changes required on the API side.


Important

Add PostgreSQL support and ensure migrations run on PostgreSQL, with updates to provider configuration and migration scripts.

  • PostgreSQL Support:
    • Add PostgreSQL provider in pkg/sqlstore/postgressqlstore/provider.go.
    • Update pkg/sqlstore/config.go to include PostgresConfig.
    • Add pgdialect to go.mod and go.sum.
  • Migrations:
    • Add NewModifyDatetimeFactory in pkg/sqlmigration/011_modify_datetime.go to handle datetime modifications for SQLite.
    • Update created_at and updated_at fields in pkg/sqlmigration/003_add_dashboards.go, 004_add_saved_views.go, and 005_add_agents.go to remove type:datetime.
  • Miscellaneous:
    • Update dependencies in go.mod and go.sum to include PostgreSQL related packages.
    • Comment out postgressqlstore.NewFactory() in pkg/signoz/provider.go.

This description was created by Ellipsis for d3040d3. It will automatically update as commits are pushed.

@github-actions github-actions bot added the bug Something isn't working label Feb 11, 2025
@nityanandagohain nityanandagohain marked this pull request as ready for review February 11, 2025 11:35
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 76d7a21 in 2 minutes and 57 seconds

More details
  • Looked at 1646 lines of code in 24 files
  • Skipped 0 files when reviewing.
  • Skipped posting 10 drafted comments based on config settings.
1. pkg/signoz/provider.go:61
  • Draft comment:
    Added NewModifyDatetimeFactory() call seems correctly added as a migration factory. No issues detected.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
2. pkg/sqlmigration/011_modify_datetime.go:31
  • Draft comment:
    The migration runs only for sqlite as intended; ensure table and column names used in dynamic SQL are safe.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50%
    None
3. pkg/sqlstore/config.go:38
  • Draft comment:
    Default provider is set to 'sqlite'; ensure this matches deployment intent when using Postgres.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50%
    None
4. pkg/types/license.go:12
  • Draft comment:
    Timestamp defaults are inconsistent in casing (e.g., 'current_timestamp' vs 'CURRENT_TIMESTAMP'); standardize casing for clarity.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
5. pkg/signoz/provider.go:61
  • Draft comment:
    Consider verifying the ordering and naming conventions of migration factories; the new addition of NewModifyDatetimeFactory is clear, but documentation may help future maintainers.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50%
    None
6. pkg/sqlmigration/001_add_organization.go:70
  • Draft comment:
    Remove the extraneous trailing comma in the OrgID field's tag to avoid potential parsing issues.
  • Reason this comment was not posted:
    Marked as duplicate.
7. pkg/sqlmigration/011_modify_datetime.go:67
  • Draft comment:
    The raw SQL concatenation used for renaming, adding, updating, and dropping columns is safe since table and column names are hardcoded; ensure you test this thoroughly on your supported SQLite versions.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    This comment is asking the PR author to ensure thorough testing, which violates the rule against asking for confirmation or testing. It doesn't provide a specific suggestion or point out a specific issue with the code.
8. pkg/sqlstore/pgstore/provider.go:33
  • Draft comment:
    Avoid logging the full DSN in plaintext as it may expose sensitive connection details; consider masking passwords or sensitive parts of the DSN.
  • Reason this comment was not posted:
    Marked as duplicate.
9. pkg/types/license.go:13
  • Draft comment:
    Standardize the naming convention for timestamp tags; here 'createdAt' is used while other models use 'created_at'. Consistency may reduce confusion.
  • Reason this comment was not posted:
    Marked as duplicate.
10. General:1
  • Draft comment:
    Review consistency in date/time field types across migrations and type definitions; some use int while others use time.Time. Consistent use may prevent runtime issues when switching DB providers.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_RvNeTskQbCbQie3h


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

nityanandagohain and others added 3 commits February 11, 2025 17:09
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Incremental review on 55fd488 in 1 minute and 34 seconds

More details
  • Looked at 167 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. pkg/signoz/provider.go:49
  • Draft comment:
    Consider updating the commented postgres provider factory name if this provider is intended to be enabled. Also ensure the scoped package path (if used elsewhere) reflects the new name (postgressqlstore) instead of 'pgstore'.
  • Reason this comment was not posted:
    Marked as duplicate.
2. pkg/signoz/provider.go:47
  • Draft comment:
    The Postgres SQL store provider factory is currently commented out. Make sure this is intended—if you want to support Postgres for migrations, consider uncommenting it or gating it behind a configuration flag.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 40% <= threshold 50%
    This comment is asking the author to confirm their intention regarding the commented-out code. It suggests uncommenting or using a configuration flag if Postgres support is desired. This aligns with the rule that allows for specific code suggestions, such as "Did you mean to do X". However, it also asks the author to "make sure this is intended," which violates the rule against asking for confirmation of intention.
3. pkg/sqlstore/postgressqlstore/provider.go:41
  • Draft comment:
    Instead of modifying pool.Config().MaxConns after creating the pool, set the MaxConns value on pgConfig before calling pgxpool.NewWithConfig. This ensures the connection limit is correctly applied from the start.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_agrw7wnMCbdWiafk


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 9b929c9 in 1 minute and 52 seconds

More details
  • Looked at 23 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. pkg/sqlstore/postgressqlstore/provider.go:35
  • Draft comment:
    Good change: setting pgConfig.MaxConns before creating the pool ensures the connection limit is applied properly. Removing the redundant pool.Config().MaxConns assignment cleans up the code.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
2. pkg/sqlstore/postgressqlstore/provider.go:35
  • Draft comment:
    Good: Setting MaxConns on pgConfig before pool creation ensures the limit is applied at initialization.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
3. pkg/sqlstore/postgressqlstore/provider.go:44
  • Draft comment:
    Removed redundant post-creation MaxConns setting; now solely configured via pgConfig which is cleaner.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50%
    None
4. pkg/sqlstore/postgressqlstore/provider.go:1
  • Draft comment:
    Note: The commit message mentions a UI bug (feedback button) which isn't reflected in these changes. Ensure that UI fixes and DB provider changes are documented/separated consistently.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50%
    None

Workflow ID: wflow_LtuqoWo1f3YdKTb4


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@nityanandagohain nityanandagohain enabled auto-merge (squash) February 12, 2025 13:15
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on d3040d3 in 1 minute and 0 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. pkg/sqlstore/postgressqlstore/provider.go:28
  • Draft comment:
    Update ScopedProviderSettings string to reflect the correct package name ('postgressqlstore') rather than the outdated 'pgstore'.
  • Reason this comment was not posted:
    Marked as duplicate.
2. pkg/sqlstore/postgressqlstore/provider.go:28
  • Draft comment:
    Updated scoped provider settings string now correctly uses 'postgressqlstore' instead of 'pgstore'. Please ensure that all references to the old string have been updated so that migrations run as expected.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    This comment is asking the author to ensure that all references have been updated, which is against the rules. It is not making a specific suggestion or pointing out a specific issue.
3. pkg/sqlstore/postgressqlstore/provider.go:27
  • Draft comment:
    The PR description references a UI issue with the product feedback button, but the diff only addresses the postgres provider. Confirm that the fix for UI is handled elsewhere or update the PR description.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50%
    This comment asks the PR author to confirm if the UI issue is handled elsewhere or to update the PR description. This violates the rule against asking the author to update the PR description or confirm intentions.

Workflow ID: wflow_tdUXkNWunWqzQyVP


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@nityanandagohain nityanandagohain merged commit 7a03a09 into main Feb 12, 2025
14 of 16 checks passed
@nityanandagohain nityanandagohain deleted the issue_453 branch February 12, 2025 13:23
hudsongeovane pushed a commit to hudsongeovane/signoz that referenced this pull request Feb 22, 2025
* fix: move migrations to bun

* fix: use anonymous structs and move modes to types package

* fix: minor changes after tests

* fix: remove bun relations and add foreign keys

* fix: minor changes

* Update pkg/types/agent.go

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* fix: add migration and postgres provider

* fix: address minor comments

* fix: use bun create index

* fix: add migration

* fix: support for postgres in migrations

* Update pkg/sqlstore/pgstore/provider.go

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* Update pkg/sqlmigration/001_add_organization.go

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* fix: address comments

* fix: move max connection to base config

* fix: update scope

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants