Fix tests and fix migrations to always explicitly include nullable()

This commit is contained in:
Brady Wetherington 2025-02-22 12:15:12 +00:00
parent 7b930357e4
commit 7e1295bac7
14 changed files with 28 additions and 25 deletions

View file

@ -12,8 +12,8 @@ class AddSoftDeletedToLog extends Migration
*/ */
public function up() public function up()
{ {
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform(); //$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string'); //$platform->registerDoctrineTypeMapping('enum', 'string');
Schema::table('asset_logs', function ($table) { Schema::table('asset_logs', function ($table) {
$table->string('asset_type', 100)->nullable()->change(); $table->string('asset_type', 100)->nullable()->change();

View file

@ -14,7 +14,7 @@ class ChangeLicenseNotesType extends Migration
{ {
// //
Schema::table('licenses', function ($table) { Schema::table('licenses', function ($table) {
$table->text('notes')->change(); $table->text('notes')->nullable()->change();
}); });
} }

View file

@ -12,7 +12,7 @@ class MigrateMacAddress extends Migration
*/ */
public function up() public function up()
{ {
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); //DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
$f2 = new \App\Models\CustomFieldset(['name' => 'Asset with MAC Address']); $f2 = new \App\Models\CustomFieldset(['name' => 'Asset with MAC Address']);
$f2->timestamps = false; //when this model was first created, it had no timestamps. But later on it gets them. $f2->timestamps = false; //when this model was first created, it had no timestamps. But later on it gets them.

View file

@ -13,7 +13,7 @@ class UpdateLdapFilterToLongerField extends Migration
public function up() public function up()
{ {
Schema::table('settings', function (Blueprint $table) { Schema::table('settings', function (Blueprint $table) {
$table->text('ldap_filter')->default(null)->change(); $table->text('ldap_filter')->nullable()->default(null)->change();
}); });
} }

View file

@ -12,8 +12,8 @@ class MakePurchaseCostNullable extends Migration
*/ */
public function up() public function up()
{ {
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform(); //$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string'); //$platform->registerDoctrineTypeMapping('enum', 'string');
Schema::table('assets', function ($table) { Schema::table('assets', function ($table) {
$table->decimal('purchase_cost', 8, 2)->nullable()->default(null)->change(); $table->decimal('purchase_cost', 8, 2)->nullable()->default(null)->change();

View file

@ -12,8 +12,8 @@ class IncreasePurchaseCostSize extends Migration
*/ */
public function up() public function up()
{ {
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform(); //$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string'); //$platform->registerDoctrineTypeMapping('enum', 'string');
Schema::table('assets', function ($table) { Schema::table('assets', function ($table) {
$table->decimal('purchase_cost', 20, 2)->nullable()->default(null)->change(); $table->decimal('purchase_cost', 20, 2)->nullable()->default(null)->change();
@ -47,8 +47,8 @@ class IncreasePurchaseCostSize extends Migration
*/ */
public function down() public function down()
{ {
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform(); //$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string'); //$platform->registerDoctrineTypeMapping('enum', 'string');
Schema::table('assets', function ($table) { Schema::table('assets', function ($table) {
$table->decimal('purchase_cost', 8, 2)->nullable()->default(null)->change(); $table->decimal('purchase_cost', 8, 2)->nullable()->default(null)->change();

View file

@ -43,8 +43,8 @@ class FixUtf8CustomFieldColumnNames extends Migration
*/ */
public function up() public function up()
{ {
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform(); //$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string'); //$platform->registerDoctrineTypeMapping('enum', 'string');
if (! Schema::hasColumn('custom_fields', 'db_column')) { if (! Schema::hasColumn('custom_fields', 'db_column')) {
Schema::table('custom_fields', function ($table) { Schema::table('custom_fields', function ($table) {

View file

@ -13,11 +13,11 @@ class SetAssetArchivedToZeroDefault extends Migration
*/ */
public function up() public function up()
{ {
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform(); //$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string'); //$platform->registerDoctrineTypeMapping('enum', 'string');
Schema::table('assets', function (Blueprint $table) { Schema::table('assets', function (Blueprint $table) {
$table->boolean('archived')->default(0)->change(); $table->boolean('archived')->default(0)->nullable()->change();
}); });
} }

View file

@ -13,8 +13,8 @@ class MakeSerialNullable extends Migration
*/ */
public function up() public function up()
{ {
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform(); //$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string'); //$platform->registerDoctrineTypeMapping('enum', 'string');
Schema::table('assets', function (Blueprint $table) { Schema::table('assets', function (Blueprint $table) {
$table->string('serial')->nullable()->default(null)->change(); $table->string('serial')->nullable()->default(null)->change();

View file

@ -29,7 +29,7 @@ class PassportUpgrade extends Migration
{ {
if (Schema::hasTable('oauth_clients')) { if (Schema::hasTable('oauth_clients')) {
Schema::table('oauth_clients', function (Blueprint $table) { Schema::table('oauth_clients', function (Blueprint $table) {
$table->string('secret', 100)->change(); $table->string('secret', 100)->nullable(false)->change();
}); });
} }
} }

View file

@ -14,7 +14,7 @@ class ChangeWebhookSettingsVariableType extends Migration
public function up() public function up()
{ {
Schema::table('settings', function (Blueprint $table) { Schema::table('settings', function (Blueprint $table) {
$table->text('webhook_endpoint')->change(); $table->text('webhook_endpoint')->nullable()->change();
}); });
} }
@ -26,7 +26,7 @@ class ChangeWebhookSettingsVariableType extends Migration
public function down() public function down()
{ {
Schema::table('settings', function (Blueprint $table) { Schema::table('settings', function (Blueprint $table) {
$table->string('webhook_endpoint')->change(); $table->string('webhook_endpoint')->nullable()->change();
}); });
} }

View file

@ -21,7 +21,7 @@ return new class extends Migration {
*/ */
if (Schema::hasTable('report_templates') && Schema::hasColumn('report_templates', 'options')) { if (Schema::hasTable('report_templates') && Schema::hasColumn('report_templates', 'options')) {
Schema::table('report_templates', function (Blueprint $table) { Schema::table('report_templates', function (Blueprint $table) {
$table->text('options')->change(); $table->text('options')->nullable(false)->change();
}); });
} }
} }

View file

@ -28,8 +28,8 @@ return new class extends Migration
]); ]);
Schema::table('settings', function (Blueprint $table) { Schema::table('settings', function (Blueprint $table) {
$table->string('label2_2d_type')->default('QRCODE')->change(); $table->string('label2_2d_type')->default('QRCODE')->nullable(false)->change();
$table->string('label2_1d_type')->default('C128')->change(); $table->string('label2_1d_type')->default('C128')->nullable(false)->change();
}); });
} }

View file

@ -21,6 +21,8 @@ use Tests\TestCase;
class ShowSetUpPageTest extends TestCase class ShowSetUpPageTest extends TestCase
{ {
static ?TestResponse $latestResponse;
/** /**
* We do not want to make actual http request on every test to check .env file * We do not want to make actual http request on every test to check .env file
* visibility because that can be really slow especially in some cases where an * visibility because that can be really slow especially in some cases where an
@ -34,7 +36,8 @@ class ShowSetUpPageTest extends TestCase
Http::fake([URL::to('.env') => Http::response(null, 404)]); Http::fake([URL::to('.env') => Http::response(null, 404)]);
} }
return $this->get('/setup'); self::$latestResponse = $this->get('/setup');
return self::$latestResponse;
} }
public function testView(): void public function testView(): void