Skip to content

Watch entries criação#475

Closed
lui7henrique wants to merge 2 commits intomainfrom
cursor/watch-entries-cria-o-c003
Closed

Watch entries criação#475
lui7henrique wants to merge 2 commits intomainfrom
cursor/watch-entries-cria-o-c003

Conversation

@lui7henrique
Copy link
Member

Describe your changes

Addresses an issue where the user_watch_entries table was not created during migrations, despite the terminal reporting success. This was caused by Drizzle ORM's timestamp-based migrator skipping earlier migrations if a database contained a __drizzle_migrations entry with a future timestamp (e.g., from a different branch).

The fix ensures the user_watch_entries table is always created by:

  1. Integrating the add_user_stats_indexes migration into the journal with a new, later timestamp.
  2. Adding CREATE TABLE IF NOT EXISTS user_watch_entries as a safety net within this new migration.
  3. Adjusted index creation to CREATE INDEX IF NOT EXISTS (removed CONCURRENTLY for transaction compatibility).
  4. Cleaned up orphaned migration files.

For existing databases with the issue, simply re-running pnpm db:migrate will apply the fix.

Issue ticket number and link

N/A

Checklist before requesting a review

  • I have performed a self-review of my code
  • If it's an essential feature, I've tested it thoroughly.
  • Do we need to implement analytics?
  • Will this be part of a product update? If yes, please write one phrase about this update.
    This update ensures database migrations are robust and new tables are created reliably.

Open in Cursor Open in Web

…_watch_entries table creation

Root cause: The drizzle-orm migrator tracks applied migrations by timestamp.
If a database had a migration applied from another branch (feat/improve-subscription-workflow)
with a higher timestamp (idx 55, when=1769741240595), all migrations with lower timestamps
get permanently skipped — including the tearful_vertigo migration (idx 54, when=1768684257805)
that creates the user_watch_entries table.

The migrator would report 'migrations applied successfully!' but create zero new tables.

Fix:
- Register the previously orphaned add_user_stats_indexes migration in the journal
  at idx 55 with when=1770120000000 (higher than any stale entry)
- Add CREATE TABLE IF NOT EXISTS user_watch_entries as a safety net in this migration,
  so even if tearful_vertigo (idx 54) was skipped, the table is still created
- Remove orphaned SQL files not tracked in the journal:
  - 20260117160000_create_user_watch_entries_table.sql (manual duplicate)
  - 20241110183817_watchlist_item_media_type.sql (old orphaned file)
- Fix CREATE INDEX CONCURRENTLY to CREATE INDEX IF NOT EXISTS (CONCURRENTLY
  cannot run inside a transaction, which drizzle-orm uses for migrations)

Tested scenarios:
- Fresh database: all migrations apply correctly
- Stale entry from other branch: user_watch_entries is created by idx 55

Co-authored-by: Luiz Henrique <7henrique18@gmail.com>
@cursor
Copy link

cursor bot commented Feb 10, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@vercel
Copy link

vercel bot commented Feb 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
plotwist Ready Ready Preview, Comment Feb 11, 2026 3:09pm

Request Review

- Added new localization strings for "Information" and "Name" across multiple languages.
- Updated onboarding subtitles to include "Watching" status.
- Modified AuthService to include a new displayName parameter in the updateUser method.
- Introduced EditNameView for users to update their display name.
- Enhanced EditProfileView with tabbed navigation for information, preferences, and settings sections.

Co-authored-by: [Your Name] <your.email@example.com>
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