Skip to content

fix: add missing wakatime_stats table to canonical schema.sql (#2951)#3148

Open
yachikadev wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
yachikadev:fix/issue-2951-wakatime-stats-schema-sync
Open

fix: add missing wakatime_stats table to canonical schema.sql (#2951)#3148
yachikadev wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
yachikadev:fix/issue-2951-wakatime-stats-schema-sync

Conversation

@yachikadev

Copy link
Copy Markdown
Contributor

Fixes #2951

Problem

The wakatime_stats table (added via migration 20260526000000_add_wakatime_stats.sql) was never backported to supabase/schema.sql. Self-hosters who bootstrap their database directly from schema.sql end up missing this table, causing: relation "public.wakatime_stats" does not exist
when WakaTime sync (/api/wakatime/sync) runs.

Changes

  • Added the wakatime_stats table definition to supabase/schema.sql, matching the migration exactly (columns, FK to users(id), unique constraint on user_id, date).
  • Enabled RLS and added the "Users can view their own wakatime stats" SELECT policy.
  • Placed it alongside the other per-user caching tables (near local_coding_sessions / user_sponsor_metrics) for consistency.
  • Fixed an unrelated stray ); after the leaderboard_cache table definition that was causing a SQL syntax error and breaking a fresh schema.sql run before it could even reach the new table.

Testing

  • Ran schema.sql against a fresh local Supabase Postgres instance — all tables (including wakatime_stats) now create successfully.
  • Verified user_id TEXT correctly matches users.id (also TEXT), so the foreign key resolves without casting issues.
  • Confirmed migration file and schema.sql are now consistent for this table.

Notes for reviewer

The stray ); fix is a small drive-by fix needed to unblock testing this PR — happy to split it into a separate PR if preferred.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:feature GSSoC type bonus: new feature labels Jul 5, 2026
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:feature GSSoC type bonus: new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] : Missing Table in Canonical Schema Setup

1 participant