Skip to content

Commit 57e0344

Browse files
Tofandelifox
authored andcommitted
Ask to create the migrations
1 parent fea7221 commit 57e0344

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

src/Commands/Traits/HandlesPotentialBreakingChangesWarnings.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,30 @@ public function warnAboutNewPositionColumns(): void
2626
return;
2727
}
2828

29-
$this->warn('⚠️ Twill 3.5.0 introduced 2 new database migrations to fix a bug with the medias and files fields position management, make sure to add them to your project.');
30-
$this->warn("\nAdd position field to the twill_mediables table:");
31-
$this->info('🔗 https://github.com/area17/twill/blob/3.5.0/migrations/default/2020_02_09_000015_add_position_to_twill_default_mediables_table.php');
32-
$this->warn("\nAdd position field to the twill_fileables table:");
33-
$this->info('🔗 https://github.com/area17/twill/blob/3.5.0/migrations/default/2020_02_09_000016_add_position_to_twill_default_fileables_table.php');
29+
$this->warn("⚠️ Twill 3.5.0 introduced 2 new database migrations to fix a bug with the medias and files fields position management, make sure to add them to your project.\n");
30+
31+
if ($this->ask('Would you like to add the migration to your project?')) {
32+
if (! $mediablesHasPosition) {
33+
copy(
34+
__DIR__ . '/../../../migrations/default/2020_02_09_000015_add_position_to_twill_default_mediables_table.php',
35+
database_path() . '/migrations/' . date('Y_m_d_His') . '_add_position_to_twill_default_mediables_table.php'
36+
);
37+
}
38+
if (! $fileablesHasPosition) {
39+
copy(
40+
__DIR__ . '/../../../migrations/default/2020_02_09_000016_add_position_to_twill_default_fileables_table.php',
41+
database_path() . '/migrations/' . date('Y_m_d_His') . '_add_position_to_twill_default_fileables_table.php'
42+
);
43+
}
44+
} else {
45+
if (! $mediablesHasPosition) {
46+
$this->info('You can find the migration source there:');
47+
$this->info('🔗 https://raw.githubusercontent.com/area17/twill/refs/tags/3.5.0/migrations/default/2020_02_09_000015_add_position_to_twill_default_mediables_table.php');
48+
}
49+
if (! $fileablesHasPosition) {
50+
$this->info('You can find the migration source there:');
51+
$this->info('🔗 https://raw.githubusercontent.com/area17/twill/refs/tags/3.5.0/migrations/default/2020_02_09_000016_add_position_to_twill_default_fileables_table.php');
52+
}
53+
}
3454
}
3555
}

0 commit comments

Comments
 (0)