Merge pull request #16028 from marcusmoore/fixes/report-template-column
Some checks are pending
Crowdin Action / upload-sources-to-crowdin (push) Waiting to run
Docker images (Alpine) / docker (push) Waiting to run
Docker images / docker (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.1) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.2) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.3) (push) Waiting to run
Tests in SQLite / PHP ${{ matrix.php-version }} (8.1.1) (push) Waiting to run
CodeQL Security Scan / CodeQL Security Scan (javascript) (push) Waiting to run
Codacy Security Scan / Codacy Security Scan (push) Waiting to run

Fixed migration causing issues with mariadb
This commit is contained in:
snipe 2025-01-06 22:58:30 +00:00 committed by GitHub
commit f698f74d3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 52 additions and 1 deletions

View file

@ -17,7 +17,19 @@ class CreateReportTemplatesTable extends Migration
$table->id(); $table->id();
$table->integer('created_by')->nullable(); $table->integer('created_by')->nullable();
$table->string('name'); $table->string('name');
$table->json('options');
/*
* The "options" column was originally json but this causes issues
* with older versions of mariadb so it was changed text.
*
* A follow-up migration definitively changes it to a text column
* for the systems that had successfully run the migration:
* 2025_01_06_210534_change_report_templates_options_to_column_text_field.
*
* https://github.com/snipe/snipe-it/issues/16015
*/
$table->text('options');
$table->softDeletes(); $table->softDeletes();
$table->timestamps(); $table->timestamps();
$table->index('created_by'); $table->index('created_by');

View file

@ -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.
});
}
};