{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/8670","labels_url":"https://api.github.com/repos/laravel/framework/issues/8670/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/8670/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/8670/events","html_url":"https://github.com/laravel/framework/issues/8670","id":74461545,"number":8670,"title":"Breaking Change in 5.0.29 with `artisan migrate:reset`","user":{"login":"pvormittag","id":211588,"avatar_url":"https://avatars.githubusercontent.com/u/211588?v=3","gravatar_id":"","url":"https://api.github.com/users/pvormittag","html_url":"https://github.com/pvormittag","followers_url":"https://api.github.com/users/pvormittag/followers","following_url":"https://api.github.com/users/pvormittag/following{/other_user}","gists_url":"https://api.github.com/users/pvormittag/gists{/gist_id}","starred_url":"https://api.github.com/users/pvormittag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pvormittag/subscriptions","organizations_url":"https://api.github.com/users/pvormittag/orgs","repos_url":"https://api.github.com/users/pvormittag/repos","events_url":"https://api.github.com/users/pvormittag/events{/privacy}","received_events_url":"https://api.github.com/users/pvormittag/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-05-08T19:03:45Z","updated_at":"2015-05-08T20:13:17Z","closed_at":"2015-05-08T19:10:13Z","body":"### TL;DR\r\n\r\nThis [commit](https://github.com/laravel/framework/commit/5792da9476c07c8e89dbb8d4e7fd4ab7b0bf87f7) appears to introduce a breaking change where migrations are reversed in an order which does not respect the batch number. I noticed the issue while running `php artisan migrate:reset`.\r\n\r\n### The Issue\r\n\r\nI have a migrations table as follows:\r\n\r\n| migration                                                    | batch |\r\n|--------------------------------------------------------------|-------|\r\n| 2015_01_01_000001_create_sapling_environment_variables_table | 1     |\r\n| 2015_01_01_000001_create_oauth_sessions_table                | 2     |\r\n| 2015_01_01_000001_create_initial_transit_tables              | 3     |\r\n| 2015_01_01_000001_create_initial_core_resident_tables        | 4     |\r\n| 2015_03_01_000001_create_initial_core_portfolio_tables       | 5     |\r\n| 2015_01_01_000001_create_initial_core_keychain_tables        | 6     |\r\n| 2015_01_01_000001_create_initial_core_assets_tables          | 7     |\r\n| 2015_01_01_000001_create_initial_core_content_blocks_tables  | 8     |\r\n| 2015_01_01_000001_create_initial_transit_foreign_keys        | 9     |\r\n| 2015_01_01_000001_create_initial_core_resident_foreign_keys  | 10    |\r\n\r\nWhen I run `php artisan migrate:reset --pretend` in Laravel `5.0.28`, I recieve the following output, which maps correctly to the migrations table by which each migration should run and their batch number.\r\n\r\n```bash\r\nCreateInitialCoreResidentForeignKeys: alter table `core_resident_portfolios` drop foreign key core_resident_portfolios_core_portfolio_id_foreign\r\nCreateInitialCoreResidentForeignKeys: alter table `core_resident_events` drop foreign key core_resident_events_portfolio_id_foreign\r\nCreateInitialCoreResidentForeignKeys: alter table `core_resident_offers` drop foreign key core_resident_offers_portfolio_id_foreign\r\nCreateInitialCoreResidentForeignKeys: alter table `core_resident_packages` drop foreign key core_resident_packages_portfolio_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_social_mashup_handle` drop foreign key transit_screens_social_m_screen_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_social_mashup_handle` drop foreign key transit_screens_social_m_provider_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_social_mashup` drop foreign key transit_screens_social_m_layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_social_mashup` drop foreign key transit_screens_social_m_image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_social_mashup` drop foreign key transit_screens_social_m_image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_weather` drop foreign key transit_screens_weather_layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_weather` drop foreign key transit_screens_weather_service_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_weather` drop foreign key transit_screens_weather_image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_weather` drop foreign key transit_screens_weather_image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_video` drop foreign key transit_screens_video_layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_video` drop foreign key transit_screens_video_service_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_video` drop foreign key transit_screens_video_image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_video` drop foreign key transit_screens_video_image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_tweet` drop foreign key transit_screens_tweet_layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_tweet` drop foreign key transit_screens_tweet_twitter_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_tweet` drop foreign key transit_screens_tweet_image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_tweet` drop foreign key transit_screens_tweet_image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_transit` drop foreign key transit_screens_transit_layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_transit` drop foreign key transit_screens_transit_service_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_transit` drop foreign key transit_screens_transit_image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_transit` drop foreign key transit_screens_transit_image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_package_notification` drop foreign key transit_screens_package__layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_package_notification` drop foreign key transit_screens_package__service_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_package_notification` drop foreign key transit_screens_package__image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_package_notification` drop foreign key transit_screens_package__image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_offer` drop foreign key transit_screens_offer_layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_offer` drop foreign key transit_screens_offer_service_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_offer` drop foreign key transit_screens_offer_image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_offer` drop foreign key transit_screens_offer_image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_message` drop foreign key transit_screens_message_layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_message` drop foreign key transit_screens_message_image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_message` drop foreign key transit_screens_message_image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_message` drop foreign key transit_screens_message_image_foreground_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_event` drop foreign key transit_screens_event_layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_event` drop foreign key transit_screens_event_service_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_event` drop foreign key transit_screens_event_image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_event` drop foreign key transit_screens_event_image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_providers` drop foreign key transit_providers_portfolio_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_providers` drop foreign key transit_providers_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_slides` drop foreign key transit_slides_channel_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_channels` drop foreign key transit_channels_portfolio_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_portfolios` drop foreign key transit_portfolios_core_portfolio_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_portfolios` drop foreign key transit_portfolios_theme_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_portfolios` drop foreign key transit_portfolios_alert_channel_id_foreign\r\nCreateInitialCoreContentBlocksTables: drop table `core_content_blocks`\r\nCreateInitialCoreAssetsTables: drop table `core_assets`\r\nCreateInitialCoreKeychainTables: drop table `core_keychain_keys`\r\nCreateInitialCorePortfolioTables: drop table `core_portfolios`\r\nCreateInitialCoreResidentTables: drop table `core_resident_packages`\r\nCreateInitialCoreResidentTables: drop table `core_resident_offers`\r\nCreateInitialCoreResidentTables: drop table `core_resident_events`\r\nCreateInitialCoreResidentTables: drop table `core_resident_portfolios`\r\nCreateInitialTransitTables: drop table `transit_screens_social_mashup_handle`\r\nCreateInitialTransitTables: drop table `transit_screens_social_mashup`\r\nCreateInitialTransitTables: drop table `transit_screens_weather`\r\nCreateInitialTransitTables: drop table `transit_screens_video`\r\nCreateInitialTransitTables: drop table `transit_screens_tweet`\r\nCreateInitialTransitTables: drop table `transit_screens_transit`\r\nCreateInitialTransitTables: drop table `transit_screens_package_notification`\r\nCreateInitialTransitTables: drop table `transit_screens_offer`\r\nCreateInitialTransitTables: drop table `transit_screens_message`\r\nCreateInitialTransitTables: drop table `transit_screens_event`\r\nCreateInitialTransitTables: drop table `transit_screen_layouts`\r\nCreateInitialTransitTables: drop table `transit_providers`\r\nCreateInitialTransitTables: drop table `transit_slides`\r\nCreateInitialTransitTables: drop table `transit_channels`\r\nCreateInitialTransitTables: drop table `transit_themes`\r\nCreateInitialTransitTables: drop table `transit_portfolios`\r\nCreateOauthSessionsTable: drop table `oauth_sessions`\r\nCreateSaplingEnvironmentVariablesTable: drop table `sapling_environment_variables`\r\n```\r\n\r\nHowever, when I run `php artisan migrate:reset --pretend` in Laravel `5.0.29`, I recieve a different output, which appears random and doesn't map back to the migrations table and the batch number. I suspect this [commit](https://github.com/laravel/framework/commit/5792da9476c07c8e89dbb8d4e7fd4ab7b0bf87f7) is the reason for this. In my case, ordering by the name of the migration without first ordering by the batch column will not produce the correct order, since the timestamp on each migration is identical. The reason they are identical is likely irrelevant, however its due to each migration being in a different composer package. A possible solution would be to order first on batch number then on migration name.\r\n\r\n```bash\r\nCreateInitialCorePortfolioTables: drop table `core_portfolios`\r\nCreateSaplingEnvironmentVariablesTable: drop table `sapling_environment_variables`\r\nCreateOauthSessionsTable: drop table `oauth_sessions`\r\nCreateInitialTransitTables: drop table `transit_screens_social_mashup_handle`\r\nCreateInitialTransitTables: drop table `transit_screens_social_mashup`\r\nCreateInitialTransitTables: drop table `transit_screens_weather`\r\nCreateInitialTransitTables: drop table `transit_screens_video`\r\nCreateInitialTransitTables: drop table `transit_screens_tweet`\r\nCreateInitialTransitTables: drop table `transit_screens_transit`\r\nCreateInitialTransitTables: drop table `transit_screens_package_notification`\r\nCreateInitialTransitTables: drop table `transit_screens_offer`\r\nCreateInitialTransitTables: drop table `transit_screens_message`\r\nCreateInitialTransitTables: drop table `transit_screens_event`\r\nCreateInitialTransitTables: drop table `transit_screen_layouts`\r\nCreateInitialTransitTables: drop table `transit_providers`\r\nCreateInitialTransitTables: drop table `transit_slides`\r\nCreateInitialTransitTables: drop table `transit_channels`\r\nCreateInitialTransitTables: drop table `transit_themes`\r\nCreateInitialTransitTables: drop table `transit_portfolios`\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_social_mashup_handle` drop foreign key transit_screens_social_m_screen_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_social_mashup_handle` drop foreign key transit_screens_social_m_provider_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_social_mashup` drop foreign key transit_screens_social_m_layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_social_mashup` drop foreign key transit_screens_social_m_image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_social_mashup` drop foreign key transit_screens_social_m_image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_weather` drop foreign key transit_screens_weather_layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_weather` drop foreign key transit_screens_weather_service_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_weather` drop foreign key transit_screens_weather_image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_weather` drop foreign key transit_screens_weather_image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_video` drop foreign key transit_screens_video_layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_video` drop foreign key transit_screens_video_service_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_video` drop foreign key transit_screens_video_image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_video` drop foreign key transit_screens_video_image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_tweet` drop foreign key transit_screens_tweet_layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_tweet` drop foreign key transit_screens_tweet_twitter_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_tweet` drop foreign key transit_screens_tweet_image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_tweet` drop foreign key transit_screens_tweet_image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_transit` drop foreign key transit_screens_transit_layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_transit` drop foreign key transit_screens_transit_service_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_transit` drop foreign key transit_screens_transit_image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_transit` drop foreign key transit_screens_transit_image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_package_notification` drop foreign key transit_screens_package__layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_package_notification` drop foreign key transit_screens_package__service_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_package_notification` drop foreign key transit_screens_package__image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_package_notification` drop foreign key transit_screens_package__image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_offer` drop foreign key transit_screens_offer_layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_offer` drop foreign key transit_screens_offer_service_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_offer` drop foreign key transit_screens_offer_image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_offer` drop foreign key transit_screens_offer_image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_message` drop foreign key transit_screens_message_layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_message` drop foreign key transit_screens_message_image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_message` drop foreign key transit_screens_message_image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_message` drop foreign key transit_screens_message_image_foreground_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_event` drop foreign key transit_screens_event_layout_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_event` drop foreign key transit_screens_event_service_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_event` drop foreign key transit_screens_event_image_preview_thumbnail__foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_screens_event` drop foreign key transit_screens_event_image_background_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_providers` drop foreign key transit_providers_portfolio_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_providers` drop foreign key transit_providers_key_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_slides` drop foreign key transit_slides_channel_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_channels` drop foreign key transit_channels_portfolio_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_portfolios` drop foreign key transit_portfolios_core_portfolio_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_portfolios` drop foreign key transit_portfolios_theme_id_foreign\r\nCreateInitialTransitForeignKeys: alter table `transit_portfolios` drop foreign key transit_portfolios_alert_channel_id_foreign\r\nCreateInitialCoreResidentTables: drop table `core_resident_packages`\r\nCreateInitialCoreResidentTables: drop table `core_resident_offers`\r\nCreateInitialCoreResidentTables: drop table `core_resident_events`\r\nCreateInitialCoreResidentTables: drop table `core_resident_portfolios`\r\nCreateInitialCoreResidentForeignKeys: alter table `core_resident_portfolios` drop foreign key core_resident_portfolios_core_portfolio_id_foreign\r\nCreateInitialCoreResidentForeignKeys: alter table `core_resident_events` drop foreign key core_resident_events_portfolio_id_foreign\r\nCreateInitialCoreResidentForeignKeys: alter table `core_resident_offers` drop foreign key core_resident_offers_portfolio_id_foreign\r\nCreateInitialCoreResidentForeignKeys: alter table `core_resident_packages` drop foreign key core_resident_packages_portfolio_id_foreign\r\nCreateInitialCoreKeychainTables: drop table `core_keychain_keys`\r\nCreateInitialCoreContentBlocksTables: drop table `core_content_blocks`\r\nCreateInitialCoreAssetsTables: drop table `core_assets`\r\n```"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/100346464","html_url":"https://github.com/laravel/framework/issues/8670#issuecomment-100346464","issue_url":"https://api.github.com/repos/laravel/framework/issues/8670","id":100346464,"user":{"login":"pvormittag","id":211588,"avatar_url":"https://avatars.githubusercontent.com/u/211588?v=3","gravatar_id":"","url":"https://api.github.com/users/pvormittag","html_url":"https://github.com/pvormittag","followers_url":"https://api.github.com/users/pvormittag/followers","following_url":"https://api.github.com/users/pvormittag/following{/other_user}","gists_url":"https://api.github.com/users/pvormittag/gists{/gist_id}","starred_url":"https://api.github.com/users/pvormittag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pvormittag/subscriptions","organizations_url":"https://api.github.com/users/pvormittag/orgs","repos_url":"https://api.github.com/users/pvormittag/repos","events_url":"https://api.github.com/users/pvormittag/events{/privacy}","received_events_url":"https://api.github.com/users/pvormittag/received_events","type":"User","site_admin":false},"created_at":"2015-05-08T20:13:17Z","updated_at":"2015-05-08T20:13:17Z","body":"@willrowe The name of the migration shouldn't matter since each migration is associated with a different batch number.\r\n\r\nAs I mentioned in the issue, the migrations are spread across many composer packages, which may or may not depend on one another. Within each package, there may be many migration files, and those do follow a naming convention of 2015_01_01_000001_*, 2015_01_01_000002_*, etc, it just happens not to be the case in my issue above... I realize it's idiomatic for Laravel to generate migration names using the current time, however, as long as an ordered sequence is maintained in the format Laraval expects, weather or not the name contains a \"true\" timestamp is irrelevant."}}