Skip to content

feat/db-add-user-id#32

Merged
cchwala merged 2 commits intomainfrom
feat/db-add-user-id
Mar 31, 2026
Merged

feat/db-add-user-id#32
cchwala merged 2 commits intomainfrom
feat/db-add-user-id

Conversation

@cchwala
Copy link
Copy Markdown
Member

@cchwala cchwala commented Mar 31, 2026

Part of #31.

Adds user_id to all three tables, updates the cml_data_1h continuous aggregate and compression segmentby, and provides migration files for existing deployments.

Files changed

  • database/init.sqluser_id column + updated PKs + indexes + update_cml_stats() signature + cml_data_1h GROUP BY + compression segmentby
  • database/migrations/001_add_user_id.sql
  • database/migrations/002_update_compression_segmentby.sql
  • database/migrations/003_update_aggregate_user_id.sql
  • database/MIGRATION.md — apply instructions for existing deployments

Backward compatibleDEFAULT 'user1' on all columns; parser and webserver need no changes.

Migration was applied and verified on a live database. Next: #31 PR 2 (feat/db-roles-rls).

cchwala added 2 commits March 31, 2026 22:18
…ntby

Part of multi-user RLS architecture (PR1 of 7).

Changes to init.sql (fresh deployments):
- cml_data: add user_id TEXT NOT NULL DEFAULT 'user1'
- cml_metadata: add user_id, PRIMARY KEY (cml_id, sublink_id, user_id),
  keep UNIQUE (cml_id, sublink_id) for backward compat until PR3
- cml_stats: add user_id, PRIMARY KEY (cml_id, user_id)
- update_cml_stats: add optional target_user_id param (DEFAULT 'user1')
  so existing single-arg call sites keep working
- cml_data_1h: add user_id to SELECT and GROUP BY
- compress_segmentby: add user_id as leading key
- Add idx_cml_data_user_id and idx_cml_metadata_user_id indexes

Migration files for existing deployments:
- database/migrations/001_add_user_id.sql
- database/migrations/002_update_compression_segmentby.sql
- database/migrations/003_update_aggregate_user_id.sql

Backward compatible: DEFAULT 'user1' + retained UNIQUE constraint mean
the unmodified parser continues to work without any code changes.
_timescaledb_internal.is_compressed_chunk() does not exist in all
TimescaleDB versions. Use the stable public view instead.
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.18%. Comparing base (19c68bc) to head (99d7dda).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #32   +/-   ##
=======================================
  Coverage   73.18%   73.18%           
=======================================
  Files          22       22           
  Lines        1965     1965           
=======================================
  Hits         1438     1438           
  Misses        527      527           
Flag Coverage Δ
mno_simulator 84.18% <ø> (ø)
parser 77.91% <ø> (ø)
webserver 49.08% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cchwala cchwala merged commit 314228c into main Mar 31, 2026
7 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.

1 participant