Skip to content

Commit 4f2353f

Browse files
committed
chore(l12): keep fresh-install columns identical without Doctrine
Restate nullable on ->change() calls, which Laravel 11+ no longer preserves. Replace unsignedDecimal with decimal()->unsigned(), set DOUBLE(12,2) on routes and DOUBLE(8,2) on the sensors thresholds in SQL since Blueprint::double() and float() drop total and places, and check indexes through TableIndexes. Fresh MySQL schema is unchanged on Laravel 10.
1 parent 811aa71 commit 4f2353f

11 files changed

Lines changed: 33 additions & 22 deletions

‎server/migrations/2023_04_27_053456_create_routes_table.php‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,19 @@ public function up()
1919
$table->char('company_uuid', 36)->nullable()->index();
2020
$table->char('order_uuid', 36)->nullable()->index();
2121
$table->json('details')->nullable();
22-
$table->double('total_distance', 12, 2)->nullable();
23-
$table->double('total_time', 12, 2)->nullable();
22+
$table->double('total_distance')->nullable();
23+
$table->double('total_time')->nullable();
2424
$table->softDeletes();
2525
$table->timestamp('created_at')->nullable()->index();
2626
$table->timestamp('updated_at')->nullable();
2727
});
28+
29+
// Blueprint::double() only takes total and places before Laravel 11, so set them in SQL.
30+
if (Schema::getConnection()->getDriverName() === 'mysql') {
31+
Schema::getConnection()->statement(
32+
'ALTER TABLE `routes` MODIFY COLUMN `total_distance` DOUBLE(12,2) NULL, MODIFY COLUMN `total_time` DOUBLE(12,2) NULL'
33+
);
34+
}
2835
}
2936

3037
/**

‎server/migrations/2023_11_03_072503_refactor_issues_table_columns.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function up()
1717
$table->string('category')->nullable()->after('type');
1818
$table->json('tags')->nullable()->after('priority');
1919
$table->json('meta')->nullable()->after('priority');
20-
$table->mediumText('report')->change();
20+
$table->mediumText('report')->nullable()->change();
2121
$table->foreignUuid('reported_by_uuid')->nullable()->after('assigned_to_uuid')->references('uuid')->on('users')->onDelete('cascade');
2222
});
2323
}
@@ -33,7 +33,7 @@ public function down()
3333
$table->string('longitude')->nullable()->after('location');
3434
$table->string('latitude')->nullable()->after('location');
3535
$table->string('odometer')->nullable()->after('location');
36-
$table->string('report')->change();
36+
$table->string('report')->nullable()->change();
3737
$table->dropForeign(['reported_by_uuid']);
3838
$table->dropColumn(['reported_by_uuid', 'meta', 'tags', 'category']);
3939
});

‎server/migrations/2024_02_18_100209_add_avatar_url_columns_table.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function up()
1414
{
1515
// Increase size of vehicles avatar url column for signed urls
1616
Schema::table('vehicles', function (Blueprint $table) {
17-
$table->mediumText('avatar_url')->change();
17+
$table->mediumText('avatar_url')->nullable()->change();
1818
});
1919

2020
// Add avatar url column to places
@@ -38,7 +38,7 @@ public function down()
3838
// @todo this can break migrations if avatar url is over 300 characters to we need to remove this and keep mediumtext
3939
// Reverse: Increase size of vehicles avatar url column for signed urls
4040
Schema::table('vehicles', function (Blueprint $table) {
41-
$table->string('avatar_url', 300)->change();
41+
$table->string('avatar_url', 300)->nullable()->change();
4242
});
4343

4444
// Reverse: Add avatar url column to places

‎server/migrations/2025_01_03_004854_increase_service_quote_amount_column.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
public function up(): void
1212
{
1313
Schema::table('service_quotes', function (Blueprint $table) {
14-
$table->bigInteger('amount')->change();
14+
$table->bigInteger('amount')->nullable()->change();
1515
});
1616
}
1717

@@ -21,7 +21,7 @@ public function up(): void
2121
public function down(): void
2222
{
2323
Schema::table('service_quotes', function (Blueprint $table) {
24-
$table->integer('amount')->change();
24+
$table->integer('amount')->nullable()->change();
2525
});
2626
}
2727
};

‎server/migrations/2025_08_28_054926_create_sensors_table.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ public function up(): void
4848

4949
$table->index(['company_uuid', 'sensor_type']);
5050
});
51+
52+
// Blueprint::float() defaulted to total and places before Laravel 11, so set them in SQL.
53+
if (Schema::getConnection()->getDriverName() === 'mysql') {
54+
Schema::getConnection()->statement(
55+
'ALTER TABLE `sensors` MODIFY COLUMN `min_threshold` DOUBLE(8,2) NULL, MODIFY COLUMN `max_threshold` DOUBLE(8,2) NULL'
56+
);
57+
}
5158
}
5259

5360
/**

‎server/migrations/2025_09_10_010724_create_additional_spec_columns_for_assets_vehicles_table.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function up(): void
2323
$table->mediumText('notes')->after('meta')->nullable();
2424
$table->string('usage_type')->after('type')->nullable();
2525
$table->string('measurement_system')->after('type')->nullable();
26-
$table->json('vin_data')->change();
26+
$table->json('vin_data')->nullable()->change();
2727
$table->renameColumn('model_data', 'specs');
2828
});
2929

@@ -70,7 +70,7 @@ public function down(): void
7070
$table->dropColumn('usage_type');
7171
$table->dropColumn('measurement_system');
7272
$table->dropColumn('ownership_type');
73-
$table->mediumText('vin_data')->change();
73+
$table->mediumText('vin_data')->nullable()->change();
7474
$table->renameColumn('specs', 'model_data');
7575
});
7676
}

‎server/migrations/2025_12_16_000003_add_performance_indexes_to_fleetops_core_tables.php‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use Fleetbase\FleetOps\Support\Database\TableIndexes;
34
use Illuminate\Database\Migrations\Migration;
45
use Illuminate\Database\Schema\Blueprint;
56
use Illuminate\Support\Facades\Schema;
@@ -430,11 +431,7 @@ public function down(): void
430431
protected function indexExists(string $table, string $index): bool
431432
{
432433
try {
433-
$connection = Schema::getConnection();
434-
$doctrineSchemaManager = $connection->getDoctrineSchemaManager();
435-
$indexes = $doctrineSchemaManager->listTableIndexes($table);
436-
437-
return isset($indexes[$index]);
434+
return isset(TableIndexes::for($table)[$index]);
438435
} catch (Exception $e) {
439436
return false;
440437
}

‎server/migrations/2026_04_08_000001_add_orchestrator_columns_to_vehicles_table.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public function up(): void
2525
// Skills / capabilities
2626
$table->json('skills')->nullable()->after('status');
2727
// Multi-dimensional capacity
28-
$table->unsignedDecimal('capacity_weight_kg', 10, 2)->nullable()->after('skills');
29-
$table->unsignedDecimal('capacity_volume_m3', 10, 3)->nullable()->after('capacity_weight_kg');
28+
$table->decimal('capacity_weight_kg', 10, 2)->unsigned()->nullable()->after('skills');
29+
$table->decimal('capacity_volume_m3', 10, 3)->unsigned()->nullable()->after('capacity_weight_kg');
3030
$table->unsignedInteger('capacity_pallets')->nullable()->after('capacity_volume_m3');
3131
$table->unsignedInteger('capacity_parcels')->nullable()->after('capacity_pallets');
3232
// Route constraints

‎server/migrations/2026_04_08_000004_add_orchestrator_columns_to_payloads_table.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
public function up(): void
2121
{
2222
Schema::table('payloads', function (Blueprint $table) {
23-
$table->unsignedDecimal('capacity_weight_kg', 10, 2)->nullable()->after('cod_currency');
24-
$table->unsignedDecimal('capacity_volume_m3', 10, 3)->nullable()->after('capacity_weight_kg');
23+
$table->decimal('capacity_weight_kg', 10, 2)->unsigned()->nullable()->after('cod_currency');
24+
$table->decimal('capacity_volume_m3', 10, 3)->unsigned()->nullable()->after('capacity_weight_kg');
2525
$table->unsignedInteger('capacity_pallets')->nullable()->after('capacity_volume_m3');
2626
$table->unsignedInteger('capacity_parcels')->nullable()->after('capacity_pallets');
2727
});

‎server/migrations/2026_04_14_000001_drop_redundant_capacity_columns_from_payloads_table.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function up(): void
3535
public function down(): void
3636
{
3737
Schema::table('payloads', function (Blueprint $table) {
38-
$table->unsignedDecimal('capacity_weight_kg', 10, 2)->nullable()->after('cod_currency');
39-
$table->unsignedDecimal('capacity_volume_m3', 10, 3)->nullable()->after('capacity_weight_kg');
38+
$table->decimal('capacity_weight_kg', 10, 2)->unsigned()->nullable()->after('cod_currency');
39+
$table->decimal('capacity_volume_m3', 10, 3)->unsigned()->nullable()->after('capacity_weight_kg');
4040
$table->unsignedInteger('capacity_pallets')->nullable()->after('capacity_volume_m3');
4141
$table->unsignedInteger('capacity_parcels')->nullable()->after('capacity_pallets');
4242
});

0 commit comments

Comments
 (0)