V1 Table Cleanup Phase 8 — Implementation Plan

For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.

Goal: Drop 16 dead v1 tables, the v1_backup schema, and all associated dead code from the Eko codebase.

Architecture: Single SQL migration drops all tables in FK-safe order, then TypeScript code cleanup removes schema definitions, query functions, type references, and re-exports atomically. The feature-flags.ts admin queries that reference already-dropped v1 tables are also gutted.

Tech Stack: Supabase Postgres (migration), Drizzle ORM (schema), TypeScript (queries/types), Bun (tooling)


Task 1: Create the SQL Migration

Files:

  • Create: supabase/migrations/0118_drop_v1_tables_phase8.sql

Step 1: Write the migration file

Create the migration following the exact pattern from migration 0111. Use DROP TABLE IF EXISTS ... CASCADE in FK-safe order (children before parents). Include:

-- ============================================================================
-- MIGRATION 0118: Drop V1 Tables — Phase 8
--
-- Removes 16 v1 tables that have no active v2 code paths, plus the v1_backup
-- schema created in Phase 6. Completes the v1 → v2 migration.
--
-- Tables dropped:
--   Page tracking: pages, page_observations, page_change_events,
--     page_change_summaries, user_pages, section_dom_mappings,
--     page_title_history, screenshot_captures
--   Notifications: sms_notification_pages, sms_delivery_log,
--     notification_delivery_log
--   User features: personas, use_cases, onboarding_state
--   Other: screen_avatars, type_metadata
--
-- Also drops:
--   - v1_backup schema (Phase 6 safety backups, now 14+ days old)
--   - Orphaned enums: avatar_source, use_case_audience, onboarding_step
--   - Orphaned functions: get_sms_page_count, can_add_sms_page
-- ============================================================================

-- ============================================================================
-- 1. Drop tables in FK-safe order (children → parents)
-- ============================================================================

-- Page tracking children (depend on pages, page_observations, page_change_events)
DROP TABLE IF EXISTS section_dom_mappings CASCADE;
DROP TABLE IF EXISTS page_title_history CASCADE;
DROP TABLE IF EXISTS screenshot_captures CASCADE;
DROP TABLE IF EXISTS page_change_summaries CASCADE;

-- Notification tables (depend on page_change_events and profiles)
DROP TABLE IF EXISTS sms_delivery_log CASCADE;
DROP TABLE IF EXISTS notification_delivery_log CASCADE;
DROP TABLE IF EXISTS sms_notification_pages CASCADE;

-- Page tracking parents
DROP TABLE IF EXISTS page_change_events CASCADE;
DROP TABLE IF EXISTS page_observations CASCADE;
DROP TABLE IF EXISTS user_pages CASCADE;
DROP TABLE IF EXISTS pages CASCADE;

-- User features
DROP TABLE IF EXISTS use_cases CASCADE;
DROP TABLE IF EXISTS personas CASCADE;
DROP TABLE IF EXISTS onboarding_state CASCADE;

-- Other
DROP TABLE IF EXISTS screen_avatars CASCADE;
DROP TABLE IF EXISTS type_metadata CASCADE;

-- ============================================================================
-- 2. Drop v1_backup schema (Phase 6 safety backups)
-- ============================================================================

DROP SCHEMA IF EXISTS v1_backup CASCADE;

-- ============================================================================
-- 3. Drop orphaned enums (only used by dropped tables)
-- ============================================================================

DROP TYPE IF EXISTS avatar_source CASCADE;
DROP TYPE IF EXISTS use_case_audience CASCADE;
DROP TYPE IF EXISTS onboarding_step CASCADE;

-- ============================================================================
-- 4. Drop orphaned functions (only used by dropped tables)
-- ============================================================================

DROP FUNCTION IF EXISTS get_sms_page_count(UUID) CASCADE;
DROP FUNCTION IF EXISTS can_add_sms_page(UUID) CASCADE;

Step 2: Verify migration file is valid SQL

Run: bun run migrations:index Expected: Index regenerates successfully with 0118 included.

Step 3: Commit

git add supabase/migrations/0118_drop_v1_tables_phase8.sql
git commit -m "feat(db): add Phase 8 migration to drop 16 v1 tables and v1_backup schema"

Task 2: Remove Drizzle Schema Definitions

Files:

  • Modify: packages/db/src/drizzle/schema.ts

Step 1: Remove table definitions and relations

Remove the following table definitions and their associated relations objects from schema.ts:

Tables to remove (including their Relations exports):

  • pages + pagesRelations (line ~728)
  • pageObservations + pageObservationsRelations (line ~770)
  • pageChangeEvents + pageChangeEventsRelations (line ~794)
  • pageChangeSummaries + pageChangeSummariesRelations (line ~815)
  • userPages + userPagesRelations (line ~847)
  • screenshotCaptures (line ~942) + any relations
  • sectionDomMappings + sectionDomMappingsRelations (line ~996)
  • pageTitleHistory + pageTitleHistoryRelations (line ~1084)
  • smsNotificationPages + smsNotificationPagesRelations (line ~373) + the smsNotificationUrls alias (line 387)
  • smsDeliveryLog + smsDeliveryLogRelations (line ~393)
  • notificationDeliveryLog + notificationDeliveryLogRelations (line ~440)
  • personas + personasRelations (line ~1177)
  • useCases (line ~1196)
  • onboardingState (line ~1251)
  • screenAvatars (line ~248)
  • typeMetadata (line ~1147)

Also remove:

  • The InlineDiff interface (line ~278) — used only by page change summaries
  • The V1 TABLES REMOVED - Phase 6 Cleanup comment block (lines ~262-273) — replace with a shorter note
  • The smsNotificationUrls deprecated alias
  • Any enum definitions used only by dropped tables: onboardingStepEnum, metadataCategoryEnum (if only used by typeMetadata), avatarSourceEnum (if defined), useCaseAudienceEnum (if defined), notificationChannelEnum, notificationDeliveryStatusEnum
  • The url_renders table REMOVED and video_renders table REMOVED comments (lines ~286-288)

Keep intact:

  • profiles, domains, brands, brandCategories, brandCategoryAssignments, planDefinitions, userSubscriptions, notificationPreferences, systemNotifications
  • All fact engine tables
  • featureFlags, aiModelTierConfig, aiCostTracking
  • Relations for kept tables (update if they reference dropped tables)

Important: Check any relations on KEPT tables that reference DROPPED tables. For example:

  • profilesRelations may have userPages, smsNotificationPages, notificationDeliveryLog, onboardingState — remove those relation entries
  • domainsRelations may reference screenAvatars — remove that
  • brandsRelations or brandCategoriesRelations may not need changes if brandCategoryAssignments is kept

Step 2: Verify TypeScript compiles

Run: bun run typecheck Expected: May fail due to import references in other files — that's expected and fixed in subsequent tasks.

Step 3: Commit

git add packages/db/src/drizzle/schema.ts
git commit -m "refactor(db): remove 16 v1 table definitions from Drizzle schema"

Task 3: Remove Dead Query Functions from drizzle/queries.ts

Files:

  • Modify: packages/db/src/drizzle/queries.ts

Step 1: Remove page tracking query functions

Remove all functions that operate on dropped tables. These include:

Page tracking (pages, pageObservations, pageChangeEvents, pageChangeSummaries, userPages):

  • listBrandUrls, updateUrlPageType, listUrlsByPageType, listUrlsWithoutPageType
  • attachUrlToUserLibrary, getUserLibrary, getUserActiveLibrary, getUserLibraryByBrand
  • getTrackedUrlsForDomainVNext, updateUserLibraryEntry, removeFromUserLibrary
  • countActiveLibraryUrls, getUserLibraryEntry
  • createUrlObservation, getObservationsForUrl, getLatestObservation
  • createUrlChangeEvent, getChangeEventsForUrl, getChangeEventsForUrlGated
  • getChangeEventById, getChangeEventByIdV1Compat
  • createUrlChangeSummary, getSummaryForChangeEvent
  • listDashboardLatestUpdates
  • getDueUrlsVNext, getDueUrlsWithLatestObservation, hasDueUrlsNotCheckedToday
  • getLatestObservationForUrl, hasCheckedTodayVNext, getTrackedUrlsVNext
  • getRecentChangesVNext, getRecentChangesWithSummariesVNext, getUrlStatsVNext
  • updateNextCheckTimeVNext
  • getUrlByCanonicalUrl, updateUrlPageDescription, updateUrlEkoNote
  • getOrCreateGlobalUrlFull, subscribeUserToUrl, getUrlWithUserSubscription
  • getEffectiveNoteForUrl, shouldUpdatePageDescription

Screenshot captures:

  • createScreenshotCapture, getScreenshotsForChange, getScreenshotsWithPairs
  • getPrimaryScreenshot, getLatestScreenshotForUrl, linkScreenshotPair
  • updateScreenshotDiff, hasRecentBaselineScreenshot, getPrimaryScreenshotForCheck
  • markScreenshotAsBefore, updateScreenshotDiffData

Section DOM mappings:

  • createSectionDomMapping, getDomMappingsForCheck, getDomMappingForSection
  • batchCreateSectionDomMappings, upsertSectionDomMapping, upsertSectionDomMappingVNext

Page title history:

  • recordPageTitleChange, getPageTitleHistory, getPageTitleChangeCount
  • getFirstRecordedTitle, hasTitleChanged

SMS notifications:

  • getSmsUrlCount, getSmsLimitForUser, canAddSmsUrl
  • getSmsNotificationUrlsForUser, isSmsEnabledForUrl, enableSmsForUrl
  • disableSmsForUrl, updateSmsPreferences, setSmsVerificationCode
  • verifySmsCode, getUsersForSmsNotification, logSmsDelivery
  • updateSmsDeliveryStatus, getRecentSmsDeliveries, isWithinSmsQuietHours
  • getPendingSmsDelivery, getNotificationPreferencesByUserId
  • getSmsDeliveryByProviderId, updateSmsDeliveryByProviderId

Notification delivery log:

  • getPendingDigestNotificationsVNext, batchCreateNotificationDeliveriesVNext
  • batchMarkNotificationsSentVNext

Screen avatars:

  • getScreenAvatarForDomain, getScreenAvatarForUrl, getScreenAvatarsBatch
  • adminListScreenAvatars, adminCountScreenAvatarsBySource
  • upsertScreenAvatar, revertScreenAvatarToOriginal, deleteScreenAvatar
  • getScreenAvatarWithDomain, searchScreenAvatars

Audience/personas:

  • getAudienceOverview, getDomainsForAudienceAdmin, getPageTypesForAudienceAdmin
  • getPersonasForAudienceAdmin, getUseCasesForAudienceAdmin
  • updateDomainAudience, updatePageTypeAudience, updatePersonaAudience
  • updateUseCaseAudience

Other dead functions:

  • hasAnyPremiumUserTrackingPage — references userUrlLibrary and pages
  • createDeepAnalysisSummary — if it depends on dropped tables
  • findRecentDomainChanges — if it queries page_change_events

Also remove:

  • SMS_LIMITS_BY_PLAN constant
  • ResolvedAvatar type
  • Any helper types only used by removed functions
  • Import statements for removed schema tables

Keep intact:

  • getUserSubscriptionWithPlan, getUserEffectivePlan, getOrCreateDomain
  • getNotificationPreferences, getFreePlan, getAllActivePlans, getDomainById
  • getOrCreateGlobalUrl, getGlobalUrlById, getGlobalUrlByCanonical
  • Brand query functions: linkDomainToBrand, findBrandForDomain, getDomainWithBrand, etc.
  • Brand category functions: getBrandCategories, getBrandPrimaryCategory, etc.
  • AI cost tracking: recordAICost, getDailyCostBreakdown, etc.
  • Domain verification functions
  • createDomainRejectionNotifications (uses systemNotifications which is kept)
  • getDomainComplexityCache, updateDomainComplexityCache

Step 2: Commit

git add packages/db/src/drizzle/queries.ts
git commit -m "refactor(db): remove dead v1 query functions from drizzle/queries.ts"

Task 4: Gut feature-flags.ts Admin Queries

Files:

  • Modify: packages/db/src/drizzle/feature-flags.ts

Step 1: Remove admin functions that reference dropped v1 tables

These functions use raw SQL that references tracked_urls, url_checks, url_changes, and summaries — tables that were dropped in Phase 6. They've been dead code since then. Remove:

  • getInlineDiffStats (references section_content_snapshots, url_changes)
  • adminSearchUrls (references tracked_urls)
  • adminListRecentUrls (references tracked_urls, url_checks, url_changes)
  • adminGetUrlDetails (references tracked_urls, url_checks, url_changes, summaries)
  • adminListRecentChanges (references url_changes, tracked_urls, summaries)
  • adminGetUrlForRequeue (references tracked_urls)
  • adminListUsers (references tracked_urls)
  • adminSearchUsers (references tracked_urls)
  • adminGetUserDetails (references tracked_urls)
  • adminGetUserNotificationPreferences — check if it uses dropped tables or notification_preferences (kept)
  • adminGetUserNotificationHistory (references notification_deliveries, url_changes, tracked_urls, summaries)
  • adminGetUserSystemNotifications — check if it uses system_notifications (kept)
  • adminGetUserRecentChanges (references url_changes, tracked_urls, summaries)
  • adminGetUserUrlStats (references tracked_urls, url_checks, url_changes)
  • adminGetUserTrackedUrls (references tracked_urls)
  • adminGetSummaryByChangeId (references summaries, url_changes, tracked_urls)
  • adminUpdateSummaryOverride (references summaries)
  • adminGetOnboardingStats (references onboarding_state)
  • adminListOnboardingStates (references onboarding_state)
  • adminGetStuckUsers (references onboarding_state)
  • adminResetUserOnboarding (references onboarding_state)
  • adminGetUserOnboardingState (references onboarding_state)
  • adminGetContentStats (references app_content — already dropped)
  • adminListContent (references app_content)
  • adminGetContentByKey (references app_content)
  • adminGetContentById (references app_content)
  • adminUpdateContent (references app_content)
  • adminResetContent (references app_content)
  • adminUpsertContent (references app_content)
  • adminBulkUpsertContent (references app_content)
  • getContentValue (references app_content)
  • getContentValues (references app_content)

Keep intact:

  • getFeatureFlag, isFeatureEnabled, isFeatureEnabledSafe
  • isAIProviderEnabled, getFeatureFlagConfig, getInlineDiffsConfig
  • getAIModelTierConfig, listFeatureFlags, updateFeatureFlag, upsertFeatureFlag

Step 2: Commit

git add packages/db/src/drizzle/feature-flags.ts
git commit -m "refactor(db): remove dead admin queries from feature-flags.ts"

Task 5: Remove Dead Functions from queries.ts (Supabase Client)

Files:

  • Modify: packages/db/src/queries.ts

Step 1: Remove v1 Supabase-client query functions

Remove all functions that operate on dropped v1 tables (tracked_urls, url_checks, url_changes, summaries, pages, user_pages, etc.). This file has extensive v1 functions. Remove:

Tracked URL functions:

  • countActiveTrackedUrls, getTrackedUrlsByUser, getTrackedUrlById
  • createTrackedUrl, updateTrackedUrl, deleteTrackedUrl
  • getDueUrls, updateNextCheckTime
  • getTrackedUrlsForDomain (deprecated stub), getTrackedUrlsWithDomain (deprecated stub)

URL check functions:

  • getLatestCheck, getChecksForUrl, hasCheckedToday, createUrlCheck
  • batchCreateUrlChecks

URL change functions:

  • getChangesForUrl, createUrlChange

Summary functions:

  • getSummaryForChange, createSummary

URL render functions:

  • createUrlRender, getRendersForUrl, getLatestRenderForUrl

Notification delivery functions (v1 versions):

  • createNotificationDelivery, updateNotificationDeliveryStatus
  • batchCreateNotificationDeliveries, batchMarkNotificationsSent
  • getPendingDigestNotifications

User library / URL management:

  • getOrCreateGlobalUrlByCanonical, getGlobalUrlById, listBrandUrls
  • attachUrlToUserLibrary, getUserLibrary, updateUserLibraryEntry
  • removeFromUserLibrary, countActiveLibraryUrls
  • listUrlUpdateInstances, getUpdateInstanceDetail, listDashboardLatestUpdates
  • createUrlObservation, createUrlChangeEvent, createUrlChangeSummary
  • updateUrlPageType, listUrlsByPageType, listUrlsWithoutPageType
  • updateTrackedUrlEkoNote

Folder functions (all — tables already dropped):

  • All getUserFolders, getFolderById, createFolder, updateFolder, deleteFolder
  • All getFolderUrls, addUrlToFolder, removeUrlFromFolder, etc.
  • All getUserFavoriteFolders, createFavoriteFolder, etc.
  • All markUrlAsRead, markFolderUrlsAsRead, getFolderUnreadCounts
  • getUserSavedItems, getSavedItemCounts, saveItem, unsaveItem, etc.

Page/brand type metadata:

  • getAllPageTypeMetadata, getPageTypeMetadata, getFeaturedUrlsForPageType (deprecated)
  • getUserUrlCountsByPageType (deprecated), getUrlsForPageType (deprecated)
  • getAllBrandTypeMetadata, getBrandTypeMetadata, getFeaturedDomainsForType (deprecated)
  • getUserUrlCountsByBrandType (deprecated), getDomainsForType (deprecated)

Persona/onboarding:

  • getAllPersonas, getPersonaBySlug, getFeaturedUseCasesForPersona
  • getUseCasesForPersona, getUseCaseById
  • getOnboardingState, createOnboardingState, getOrCreateOnboardingState
  • updateOnboardingStep, completeOnboarding, skipOnboarding, hasCompletedOnboarding

Usage stats (references tracked_urls/url_changes):

  • getMonthlyUsageStats — references tracked_urls and url_changes
  • getUserTotalChangesCount — references url_changes
  • Milestone functions: getUrlMilestone, getChangeMilestone — keep if pure logic, remove if they query dropped tables
  • hasMilestoneNotification — check if it uses system_notifications (kept) or dropped tables

Also remove:

  • All type definitions only used by removed functions (TrackedUrl, UrlCheck, UrlChange, Summary, UserFolder, FolderUrlEntry, FolderUsage, OnboardingStateRow, PersonaRow, UseCaseRow, PageTypeMetadataRow, BrandTypeMetadataRow, SavedItemCounts, etc.)
  • Dead interfaces
  • Dead enum re-exports

Keep intact:

  • getUserSubscriptionWithPlan, getFreePlan, getUserEffectivePlan, getUserPlanWithUrlCount
  • getOrCreateDomain, getDomainById, listUserDomains (if used)
  • getNotificationPreferences, upsertNotificationPreferences
  • getProfileDetails, upsertProfileDetails
  • All billing/subscription functions: getUserInvoices, getBillingCustomer, getAllPlans, etc.
  • createSystemNotification, hasBillingNotificationForPeriod, hasEscalationAtLevel
  • getUnreadNotificationCount, getUserSystemNotifications, markNotificationRead, etc.
  • getUserEmailById, getUserBillingPeriodStart
  • getAllActiveUsersWithEmail, hasMonthlyReportForPeriod
  • getUserAccountCreatedAt, getUsersWithAnniversaryMilestones
  • isWithinQuietHours — pure logic function, keep if used by kept notification code

Step 2: Also clean up the client.ts type definitions

Remove type definition blocks in packages/db/src/client.ts for tables that no longer exist:

  • url_checks Row/Insert/Update/Relationships (~lines 360-406)
  • url_changes Row/Insert/Update/Relationships (~lines 408-451)
  • summaries Row/Insert/Update/Relationships (~lines 453-498)
  • url_renders Row/Insert/Update/Relationships (~lines 500-550)
  • notification_deliveries if still present

Note: client.ts appears to be a manually maintained type file (not auto-generated). Remove the dead table type blocks.

Step 3: Commit

git add packages/db/src/queries.ts packages/db/src/client.ts
git commit -m "refactor(db): remove dead v1 query functions from queries.ts and client.ts"

Task 6: Clean Up Exports and Imports

Files:

  • Modify: packages/db/src/index.ts
  • Modify: Any app files that import removed symbols

Step 1: Clean up index.ts re-exports

Remove all re-exports of deleted symbols from packages/db/src/index.ts. Based on the current file:

From the drizzle/queries export block (lines 74-147), remove:

  • batchCreateSectionDomMappings, canAddSmsUrl, createScreenshotCapture
  • createSectionDomMapping, disableSmsForUrl, enableSmsForUrl
  • getAudienceOverview, getBrandsForAudienceAdmin
  • getChangeEventById, getChangeEventsForUrlGated
  • getDomMappingForSection, getDomMappingsForCheck
  • getFirstRecordedTitle, getLatestScreenshotForUrl
  • getNotificationPreferencesByUserId, getPageTitleChangeCount
  • getPageTitleHistory, getPageTypesForAudienceAdmin
  • getPendingSmsDelivery, getPersonasForAudienceAdmin
  • getPrimaryScreenshot, getPrimaryScreenshotForCheck
  • getRecentSmsDeliveries, getScreenAvatarForBrand
  • getScreenAvatarForDomain, getScreenshotsForChange
  • getScreenshotsWithPairs, getSmsDeliveryByProviderId
  • getSmsLimitForUser, getSmsNotificationUrlsForUser
  • getSmsUrlCount, getUseCasesForAudienceAdmin
  • getUsersForSmsNotification, hasRecentBaselineScreenshot
  • hasTitleChanged, isSmsEnabledForUrl, isWithinSmsQuietHours
  • linkScreenshotPair, logSmsDelivery, markScreenshotAsBefore
  • recordPageTitleChange, SMS_LIMITS_BY_PLAN
  • setSmsVerificationCode, updateBrandAudience
  • updateDomainAudience, updatePageTypeAudience
  • updatePersonaAudience, updateScreenshotDiff
  • updateScreenshotDiffData, updateSmsDeliveryByProviderId
  • updateSmsDeliveryStatus, updateSmsPreferences
  • updateUseCaseAudience, upsertSectionDomMapping
  • upsertSectionDomMappingVNext, verifySmsCode
  • Type exports: AudienceDistribution, AudienceOverview, CostBreakdownRow, RecordAICostParams — keep CostBreakdownRow and RecordAICostParams if still used

From the drizzle/schema export block (lines 148-179), remove:

  • metadataCategoryEnum, notificationChannelEnum
  • notificationDeliveryLog, notificationDeliveryStatusEnum
  • onboardingState, onboardingStepEnum
  • pageTitleHistory, personas
  • screenshotCaptures, sectionDomMappings
  • smsDeliveryLog, smsNotificationPages, smsNotificationUrls
  • systemNotificationTypeEnum — keep if systemNotifications uses it (it's kept)
  • typeMetadata, useCases
  • SystemNotificationMetadata type, TypeMetadataExtra type

Also remove or update:

  • export * as feederSourceQueries from './queries.feeder-sources' — keep if feeder_sources table is still active
  • export * from './queries' — keep but dead exports will be naturally removed since the functions are gone

Step 2: Find and fix broken imports in apps/

Search for any imports of removed symbols across the monorepo:

grep -r "from '@eko/db'" apps/ --include="*.ts" --include="*.tsx"

Key files to check:

  • apps/web/app/api/account/notifications/route.ts — imports getNotificationPreferences (kept) and upsertNotificationPreferences (kept) — should be fine
  • Any files importing SMS, screenshot, section DOM mapping, persona, onboarding, or page tracking symbols — these imports must be removed along with the code that uses them

Step 3: Commit

git add packages/db/src/index.ts
git add -u apps/  # stage any app changes
git commit -m "refactor(db): clean up exports and fix broken imports"

Task 7: Remove Dead Test Files

Files:

  • Modify: packages/db/src/__tests__/security/test-helpers.ts
  • Modify: packages/db/src/__tests__/security/tenant-isolation.test.ts
  • Modify: packages/db/src/__tests__/security/api-route-isolation.test.ts
  • Possibly delete entire test files if they only test dropped tables

Step 1: Clean up test helpers

In test-helpers.ts, remove helper functions and types that create/reference v1 tables:

  • createTrackedUrl, createUrlCheck, createUrlChange, createSummary, createNotificationDelivery helpers (if present)
  • All type definitions for dropped tables

Step 2: Clean up or remove test files

In tenant-isolation.test.ts, remove test cases for:

  • "User B CANNOT read url_checks via tracked_url_id"
  • "User B CANNOT read url_changes via tracked_url_id"
  • "User B CANNOT read summaries via url_change_id"
  • Any other tests for dropped tables

In api-route-isolation.test.ts, remove assertions referencing tracked_url_id.

If entire test files become empty after cleanup, delete them.

Step 3: Run tests

Run: bun run test Expected: All remaining tests pass.

Step 4: Commit

git add packages/db/src/__tests__/
git commit -m "test(db): remove v1 table test helpers and isolation tests"

Task 8: Regenerate Types and Indexes

Step 1: Regenerate migrations index

Run: bun run migrations:index Expected: Index regenerates with migration 0118 included.

Step 2: Verify everything compiles

Run: bun run typecheck Expected: Zero errors.

Step 3: Run full test suite

Run: bun run test Expected: All tests pass.

Step 4: Run lint

Run: bun run lint Expected: No new errors.

Step 5: Commit generated files

git add supabase/migrations-index.md
git commit -m "chore(db): regenerate migrations index for Phase 8"

Task 9: Update Changelog and Final Verification

Files:

  • Modify: docs/changelog/unreleased.md

Step 1: Add changelog entry

Add to today's date section under "Features" (or "Refactoring"):

## February 17, 2026

### Refactoring

- **Database**: Drop 16 v1 legacy tables (page tracking, SMS notifications, personas, onboarding, screen avatars, type metadata) and v1_backup schema — Phase 8 cleanup
- **Database**: Remove ~3000 lines of dead v1 query functions, type definitions, and test helpers

Step 2: Run full CI check

Run: bun run ci Expected: All checks pass.

Step 3: Commit

git add docs/changelog/unreleased.md
git commit -m "docs: add Phase 8 v1 cleanup to changelog"

Summary

TaskFilesEffort
1. SQL migration1 new fileSmall
2. Drizzle schema cleanupschema.tsMedium
3. drizzle/queries.ts cleanupqueries.tsLarge (many functions)
4. feature-flags.ts cleanupfeature-flags.tsMedium
5. queries.ts + client.ts cleanup2 filesLarge (many functions)
6. Export/import cleanupindex.ts + apps/Medium
7. Test cleanuptests/Small
8. Regenerate + verifygenerated filesSmall
9. Changelog + CIchangelogSmall