Fix: Use migration stubs and avoid duplicate migrations on republish#16
Open
scottgrayson wants to merge 1 commit intomainfrom
Open
Fix: Use migration stubs and avoid duplicate migrations on republish#16scottgrayson wants to merge 1 commit intomainfrom
scottgrayson wants to merge 1 commit intomainfrom
Conversation
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.
Details
This PR fixes how the package handles migrations so it follows Spatie conventions and avoids duplicate migration files when users republish.
Problem
.phpfiles (e.g.2024_01_01_000000_create_library_items_table.php) and were not marked as stubs.ProcessMigrationsstrips any timestamp from migration names and adds the current date when publishing, so the 2024 timestamps in the repo were never used.getMigrations()used timestamped names, the "existing file" check looked for app files ending with2024_01_01_.... Published files get a current timestamp, so the check never matched and republishing could create duplicate migration files.Solution
create_library_items_table.php.stub,create_library_item_permissions_table.php.stub,create_library_item_tags_table.php.stub,create_library_item_favorites_table.php.stub.getMigrations()to return the stub base names so the "already published?" logic works and republishing reuses the same files.TestCasenow runs the real flow (publish thenmigrate) instead of including migrations by path, so all four migrations run in order and tests match real usage.Made with Cursor