File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 33namespace A17 \Twill \Commands ;
44
55use A17 \Twill \Commands \Traits \ExecutesInTwillDir ;
6+ use A17 \Twill \Commands \Traits \HandlesPotentialBreakingChangesWarnings ;
67use Illuminate \Filesystem \Filesystem ;
78use Symfony \Component \Process \Process ;
89
910class Build extends Command
1011{
1112 use ExecutesInTwillDir;
13+ use HandlesPotentialBreakingChangesWarnings;
1214
1315 /**
1416 * The name and signature of the console command.
@@ -37,6 +39,8 @@ public function __construct(public Filesystem $filesystem)
3739 */
3840 public function handle (): void
3941 {
42+ $ this ->warnAboutNewPositionColumns ();
43+
4044 if ($ this ->option ('copyOnly ' )) {
4145 $ this ->copyCustoms ();
4246
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace A17 \Twill \Commands \Traits ;
4+
5+ use Illuminate \Support \Facades \Schema ;
6+
7+ /* @mixin \Illuminate\Console\Command */
8+ trait HandlesPotentialBreakingChangesWarnings
9+ {
10+ public function warnAboutNewPositionColumns (): void
11+ {
12+ if (config ('twill.load_default_migrations ' , true )) {
13+ return ;
14+ }
15+
16+ $ mediablesHasPosition = Schema::hasColumn (config ('twill.mediables_table ' , 'twill_mediables ' ), 'position ' );
17+ $ fileablesHasPosition = Schema::hasColumn (config ('twill.fileables_table ' , 'twill_fileables ' ), 'position ' );
18+
19+ if ($ mediablesHasPosition && $ fileablesHasPosition ) {
20+ return ;
21+ }
22+
23+ $ 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. ' );
24+ $ this ->warn ("\nAdd position field to the twill_mediables table: " );
25+ $ 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 " );
26+ $ this ->warn ("\nAdd position field to the twill_fileables table: " );
27+ $ 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 " );
28+ }
29+ }
Original file line number Diff line number Diff line change 22
33namespace A17 \Twill \Commands ;
44
5+ use A17 \Twill \Commands \Traits \HandlesPotentialBreakingChangesWarnings ;
56use Illuminate \Filesystem \Filesystem ;
67
78class Update extends Command
89{
10+ use HandlesPotentialBreakingChangesWarnings;
11+
912 protected $ signature = 'twill:update {--fromBuild} {--migrate} ' ;
1013 protected $ description = 'Publish new updated Twill assets and optionally run database migrations ' ;
1114
@@ -19,6 +22,9 @@ public function handle(): void
1922 $ this ->publishAssets ();
2023 $ this ->call ('twill:flush-manifest ' );
2124 $ this ->call ('view:clear ' );
25+
26+ $ this ->warnAboutNewPositionColumns ();
27+
2228 if ($ this ->option ('migrate ' ) || $ this ->confirm ('Do you want to run any pending database migrations now? ' )) {
2329 $ this ->call ('migrate ' );
2430 }
You can’t perform that action at this time.
0 commit comments