Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont publish migration if migration exists #692

Merged
merged 1 commit into from Feb 22, 2022

Conversation

MortenDHansen
Copy link
Contributor

@MortenDHansen MortenDHansen commented Feb 22, 2022

As suggested with pr #644

@anteriovieira
Copy link
Member

Hi @MortenDHansen , Laravel 8.37 was released with anonymous migration support, then maybe we can check if the file exists instead of the class.

sprintf('migrations/%s_create_audits_table.php', date('Y_m_d_His'))
),
], 'migrations');
if (!class_exists('CreateAuditsTable')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if the file exists instead of the class.

@MortenDHansen
Copy link
Contributor Author

Yeah, but i don't think you actually need to use the anonymous migrations if you don't want to. If we expect all existing migrations to be created as a class and we dont change how we publish it, then the class check should be enough. Spatie seems use same approach: https://github.com/spatie/laravel-translation-loader/blob/main/src/TranslationServiceProvider.php

@anteriovieira
Copy link
Member

Looks good to me! thanks

@sarukomine
Copy link

@MortenDHansen the change is not working for me, at least not working for Laravel Framework 9.9.0, I still can keep on publishing migration files. Maybe we should change the way to check if file exists instead of the class.

@MortenDHansen
Copy link
Contributor Author

Yeah, maybe my brilliant simple fix was not as brilliant as i figured, and a bit too simple :/

@MortenDHansen MortenDHansen deleted the not_publishing_migration_if_exist branch March 14, 2023 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants