I use following code in order to get desired values of attribute for bodytext. Data type should be longtext() or varchar(). DBMS is MySQL.
With following code bodytext will be created as varchar(255). Why?
$this->createTable('mail_eingang', [
'id' => $this->primaryKey(),
'mail_adresse_absender' => $this->string(255)->notNull(),
'betreff' => $this->string(255),
'bodytext' => $this->string(), //this will actually set bodytext to varchar(255). It should be longtext() or varchar() !!
'gelesen' => $this->smallInteger(1)->notNull()->defaultValue(0),
'angelegt_am' => $this->datetime(),
'angelegt_von' => $this->integer(11),
'aktualisiert_am' => $this->datetime(),
'aktualisiert_von' => $this->integer(11),
'FOREIGN KEY ([[angelegt_von]]) REFERENCES person ([[id]]) ON DELETE SET NULL ON UPDATE RESTRICT',
'FOREIGN KEY ([[aktualisiert_von]]) REFERENCES person ([[id]]) ON DELETE SET NULL ON UPDATE RESTRICT',
], $tableOptions);
If 64 KB is enough for you, you may use text():
'bodytext' => $this->text()
If you really need a longtext column, you should use something like:
'bodytext' => $this->getDb()->getSchema()->createColumnSchemaBuilder('longtext');
Or specify type as raw string:
'bodytext' => 'LONGTEXT',
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With