-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16028 from marcusmoore/fixes/report-template-column
Fixed migration causing issues with mariadb
- Loading branch information
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
39 changes: 39 additions & 0 deletions
39
...ase/migrations/2025_01_06_210534_change_report_templates_options_to_column_text_field.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration { | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
/* | ||
* The "options" column was originally json but the migration was amended to change it to a text column | ||
* since json columns cause issues with older versions of mariadb. | ||
* | ||
* This migration definitively changes it to a text column | ||
* for the systems that had successfully run the migration. | ||
* | ||
* https://github.com/snipe/snipe-it/issues/16015 | ||
*/ | ||
if (Schema::hasTable('report_templates') && Schema::hasColumn('report_templates', 'options')) { | ||
Schema::table('report_templates', function (Blueprint $table) { | ||
$table->text('options')->change(); | ||
}); | ||
} | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('report_templates', function (Blueprint $table) { | ||
// Instead of attempting to roll this back to json let's just | ||
// keep it as text since that works for mysql, mariadb, and sqlite. | ||
}); | ||
} | ||
}; |