Skip to content

Postgres primary key - #3230

Merged
schandrika merged 2 commits into
VOLTTRON:developfrom
davidraker:postgres_primary_key
Jul 7, 2026
Merged

Postgres primary key#3230
schandrika merged 2 commits into
VOLTTRON:developfrom
davidraker:postgres_primary_key

Conversation

@davidraker

Copy link
Copy Markdown
Contributor

This pull request makes a key change to the database schema setup in the setup_historian_tables function, specifically for the data table in postgresqlfuncts.py. The main update is to enforce a composite primary key on the (topic_id, ts) columns, replacing the previous unique constraint, and to remove a redundant index creation when using TimescaleDB.

Database schema improvements:

  • Changed the data table definition to use a composite primary key on (topic_id, ts) instead of a unique constraint, ensuring stronger data integrity and potentially improving query performance.
  • Removed the creation of an explicit index on (topic_id, ts) when using TimescaleDB, as the primary key already provides the necessary indexing.# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@davidraker
davidraker requested review from Copilot and schandrika and removed request for Copilot July 7, 2026 00:44
@schandrika
schandrika merged commit f356fd0 into VOLTTRON:develop Jul 7, 2026
4 of 13 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.

2 participants