Skip to content

Comments

Add database schema documentation#12

Open
mberg wants to merge 1 commit intomasterfrom
issue/ONA-2086
Open

Add database schema documentation#12
mberg wants to merge 1 commit intomasterfrom
issue/ONA-2086

Conversation

@mberg
Copy link
Member

@mberg mberg commented Jan 24, 2026

Summary

  • Created comprehensive database schema documentation at truecover-backend/docs/DATABASE_SCHEMA.md
  • Includes entity relationship diagram showing how tables connect
  • Documents all tables with columns, types, and descriptions
  • Shows foreign key relationships and constraints
  • Lists key spatial and performance indexes

Closes ONA-2086

Test plan

  • Verify the markdown renders correctly on GitHub
  • Confirm the schema matches current database state

🤖 Generated with Claude Code

Create comprehensive markdown documentation of the database schema including:
- Entity relationship diagram
- All tables with columns and types
- Foreign key relationships
- Key indexes and constraints
@linear
Copy link

linear bot commented Jan 24, 2026

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf6ebd8b83

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 111 to 114
# Get the project_id from the area
cursor.execute("""
SELECT project_id FROM areas WHERE id = %s
""", (area_id,))
""", (campaign_id,))

Choose a reason for hiding this comment

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

P1 Badge Resolve project_id via campaigns in coverage population

This refactor switched to campaign_id, but the lookup still queries areas, which the new migration renames/retire in favor of campaigns. When uploading locations for a campaign, populate_coverage_for_locations will fail to find a project and return early, so no coverage rows are created for those locations. That leaves adaptive sampling/coverage endpoints with empty data for all new uploads.

Useful? React with 👍 / 👎.

Comment on lines 28 to 31
# Get the project_id from the area
cursor.execute("""
SELECT project_id FROM areas WHERE id = %s
""", (area_id,))
""", (campaign_id,))

Choose a reason for hiding this comment

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

P1 Badge Use campaigns table for default coverage pixels

This default coverage-pixel creation now takes campaign_id, but still fetches the project from areas. After the campaign refactor, that lookup will fail and the function returns without creating any coverage_pixel rows for new pixels, which will break coverage aggregation and downstream sampling for those campaigns. The lookup should be against campaigns (or a join) so new pixels get initialized correctly.

Useful? React with 👍 / 👎.

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