Laravel 9 / PHP 8.1 / MySQL Ver 14.14 Distrib 5.7.38, for Linux (x86_64)
Our Ticketsystems Database was changed manually a few times without migrations so I adapted all migrations, took a backup, tried it locally and then did the same with the live DB.
The content of tickets is saved in the description field, which was originally a string. It was changed manually in the database to longtext. I have now changed the migration to longText as well, which creates it as longText on my local machine.
$table->longText('description')->nullable();
However it still creates it as varchar(255) on the live system and I have no idea why or where to start looking for a reason. I'd rather not screw around with changing the DB manually again.
CodePudding user response:
Why use LONGTEXT for a description, you can use TEXT type.
TEXT has a maximum length of 64 kilobytes—the same as VARCHAR.
MEDIUMTEXT has a maximum length of about 16 megabytes.
LONGTEXT has a maximum length of about 4 gigabytes.
I dont think you want to save 4GB of description in text.
So yeah, the method text()
exists in the migration schema methods (as longText() and mediumText()).
$table->text('description')->nullable();
I dont know why your getting a varchar(255), maybe it is not the right migration that you modified or you have something in your application boot that forces it.
CodePudding user response:
maybe in this case you should try to follow this approach:
Install composer require doctrine/dbal
and then change your migration to
public function up()
{
Schema::table('table_name', function (Blueprint $table) {
$table->text('description')->change();
});
}