I have a need to create a migration that changes an existing ‘unsignedMediumInteger’ column to nullable().
I have the following in my migration:
<?php
use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;
use AppNewModelsSubscriptionType;
return new class extends Migration
{
public function up()
{
Schema::table('subscription_types', function ($table) {
$table->unsignedMediumInteger('max_number_of_employees')->nullable()->change();
});
}
};
This throws an error as below:
INFO Running migrations.
2023_10_25_103141_make_subscription_types_max_number_of_employees_field_nullable 108ms FAIL
DoctrineDBALException
Unknown column type "mediuminteger" requested. Any Doctrine type that you use has to be registered with DoctrineDBALTypesType::addType(). You can get a list of all the known types with DoctrineDBALTypesType::getTypesMap(). If this error occurs during database introspection then you might have forgotten to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information.
…any pointers as to get around this please?
Thanks, K…
2
Answers
Try this approach:
The best way is to use
DB::statement
method to execute a raw SQL statement with thealter
query