Refactor database views to use external SQL files#128
Open
davidharting wants to merge 1 commit into
Open
Conversation
Introduces App\Support\DatabaseView with createOrReplace() and warnOnRollback() to eliminate raw SQL heredocs from migrations. View SQL now lives in database/views/ with proper syntax highlighting. down() methods are no-ops per the no-rollback-in-production philosophy. - New: database/views/media_tracking_summary.sql — view SELECT body - New: app/Support/DatabaseView.php — createOrReplace / warnOnRollback - Refactor: create_media_tracking_summary_view migration to use utility - New: add_creator_id_to_media_tracking_summary_view migration (one-liner up/down) https://claude.ai/code/session_01GM5ERnDYZPAWvg7tJPFcAW
davidharting
added a commit
that referenced
this pull request
Mar 28, 2026
…#128) Extracts web-search-based media identification from the main MediaTrackingAgent into a dedicated ResolveMediaTool that runs on claude-haiku-4-5-20251001. MediaTrackingAgent no longer uses WebSearch directly, reducing token costs ~1/3 per /track interaction. ResolveMediaTool accepts a raw media reference and returns a JSON array of matches (title, year, creator, media_type), handling ambiguity by returning multiple results when more than one plausible match exists. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactored the database view management system to extract SQL definitions into separate files and introduce a
DatabaseViewhelper class for consistent view creation and migration handling.Key Changes
Created
App\Support\DatabaseViewclass with two static methods:createOrReplace(): Loads SQL fromdatabase/views/{viewName}.sqland creates/replaces the viewwarnOnRollback(): Logs a warning during rollback since views cannot be safely dropped in migrationsExtracted SQL to external file: Moved the
media_tracking_summaryview definition from the migration intodatabase/views/media_tracking_summary.sqlUpdated migration (
2026_03_19_180958_create_media_tracking_summary_view.php):DB::statement()withDatabaseView::createOrReplace()DROP VIEWwithDatabaseView::warnOnRollback()Illuminate\Support\Facades\DBimport (now handled by helper class)Added new migration (
2026_03_28_023449_add_creator_id_to_media_tracking_summary_view.php):DatabaseViewhelper methodsBenefits
DatabaseViewhelper can be used across all view-related migrationshttps://claude.ai/code/session_01GM5ERnDYZPAWvg7tJPFcAW