Prevent duplicate migrations when running telescope:install#1701
Draft
JoshSalway wants to merge 6 commits intolaravel:5.xfrom
Draft
Prevent duplicate migrations when running telescope:install#1701JoshSalway wants to merge 6 commits intolaravel:5.xfrom
JoshSalway wants to merge 6 commits intolaravel:5.xfrom
Conversation
Running telescope:install multiple times creates duplicate migration files with different timestamps, which causes "table already exists" errors during migration. The install command now checks if the telescope migration already exists before publishing it. Fixes laravel#1589 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Redirect app, config, database, and bootstrap paths to a temp directory so telescope:install does not publish files into the shared testbench skeleton. This was causing all other tests to fail with "Class App\Providers\TelescopeServiceProvider not found". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add minimal composer.json with PSR-4 autoload to the temp directory and use setBasePath() instead of individual path overrides. This resolves the RuntimeException: Unable to detect application namespace error that occurs because getNamespace() reads composer.json from the base path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The full telescope:install command requires config/app.php, composer.json, and bootstrap/providers.php at the app base path, which is fragile to set up across all Laravel versions in the CI matrix. Since the PR feature is the migrationExists() check, test that method directly via reflection. Co-Authored-By: Claude Opus 4.6 (1M context) <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
Running
telescope:installmultiple times creates duplicate migration files with different timestamps, causing "table already exists" errors onphp artisan migrate.Fixes #1589
Prior attempts
This issue has been submitted twice before, and both were closed:
This PR directly addresses both concerns.
Problem
Each run of
telescope:installpublishes migration files with fresh timestamps. After running it twice:Running
php artisan migratethen fails:This commonly happens when developers re-run the install command after pulling updates or when setting up a project from scratch with existing migrations.
Solution
Addressing #1634 (code volume concern): The entire fix is a single
migrationExists()method — oneglob()call using the*_create_telescope_entries_table.phppattern. This is the same pattern Laravel's own framework uses in its install commands (e.g., Pulse, Pennant). The check is added with a singleifguard around the existingvendor:publishcall. No new dependencies, no architectural changes.Addressing #1678 (lacking explanation and tests): This PR includes 3 automated tests covering the detection logic:
test_migration_exists_returns_false_when_no_migration_present— fresh install proceeds normallytest_migration_exists_returns_true_when_migration_present— repeat install skips migration publishingtest_migration_exists_returns_false_when_directory_does_not_exist— edge case where migrations directory doesn't exist yetBefore / After
telescope:installtelescope:installphp artisan migrateafter double installWhy this doesn't break anything
telescope:install, not during normal application execution