Merge pull request #16291 from uberbrady/fix_tests_and_migrations_v8

Fix tests and fix migrations to always explicitly include nullable()
This commit is contained in:
snipe 2025-02-22 12:21:56 +00:00 committed by GitHub
commit 934da0f630
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 28 additions and 25 deletions

View file

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

View file

@ -14,7 +14,7 @@ class ChangeLicenseNotesType extends Migration
{
//
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()
{
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
//DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
$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.

View file

@ -13,7 +13,7 @@ class UpdateLdapFilterToLongerField extends Migration
public function up()
{
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()
{
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
//$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
//$platform->registerDoctrineTypeMapping('enum', 'string');
Schema::table('assets', function ($table) {
$table->decimal('purchase_cost', 8, 2)->nullable()->default(null)->change();

View file

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

View file

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

View file

@ -13,11 +13,11 @@ class SetAssetArchivedToZeroDefault extends Migration
*/
public function up()
{
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
//$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
//$platform->registerDoctrineTypeMapping('enum', 'string');
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()
{
$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
//$platform = Schema::getConnection()->getDoctrineSchemaManager()->getDatabasePlatform();
//$platform->registerDoctrineTypeMapping('enum', 'string');
Schema::table('assets', function (Blueprint $table) {
$table->string('serial')->nullable()->default(null)->change();

View file

@ -29,7 +29,7 @@ class PassportUpgrade extends Migration
{
if (Schema::hasTable('oauth_clients')) {
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()
{
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()
{
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')) {
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) {
$table->string('label2_2d_type')->default('QRCODE')->change();
$table->string('label2_1d_type')->default('C128')->change();
$table->string('label2_2d_type')->default('QRCODE')->nullable(false)->change();
$table->string('label2_1d_type')->default('C128')->nullable(false)->change();
});
}

View file

@ -21,6 +21,8 @@ use Tests\TestCase;
class ShowSetUpPageTest extends TestCase
{
static ?TestResponse $latestResponse;
/**
* 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
@ -34,7 +36,8 @@ class ShowSetUpPageTest extends TestCase
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