Closed
Description
Laravel Version
11.36.1
PHP Version
8.3.15
Database Driver & Version
SQL Server
Description
We have the problem that text fields longer than 4000 characters are not created correctly on the SQL Server, because instead of e.g. NVARCHAR(5000) we must of course use NVARCHAR(MAX)...
We use:
Schema::create('modules', function (Blueprint $table) {
$table->unsignedBigInteger('id')->primary();
$table->string('name', 5000)->nullable()->default(null);
$table->longText('options')->nullable()->default(null);
...
Is there a way to configure this?
If not, you could simply correct it in https://github.com/laravel/framework/blob/12.x/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php:
protected function typeString(Fluent $column)Add commentMore actions
{
if ($column->length > 4000){
return 'nvarchar(max)';
} else {
return "nvarchar({$column->length})";
}
}
Steps To Reproduce
Create a table with an string field and length > 4000 on MS SQL Server
Schema::create('modules', function (Blueprint $table) {
$table->unsignedBigInteger('id')->primary();
$table->string('name', 5000)->nullable()->default(null);
$table->longText('options')->nullable()->default(null);
...
Metadata
Metadata
Assignees
Labels
No labels