-1

I have to help some friends develop an app in Laravel (even though I didn't ever use PHP & Laravel) and I've just cloned their repo.

When I'm running the migration, I get this error:

Syntax error or access violation: 1118 Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs")

I've just searched for it on Google and people were telling that some of my fields are too big, such as varchars, but they're not (or I don't think they are)

Here is my migration file:

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateStudentsTable extends Migration
{
    public function up()
    {
        Schema::create('students', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('nume')->nullable()->default(NULL);
            $table->string('initiale')->nullable()->default(NULL);
            $table->string('prenume')->nullable()->default(NULL);
            $table->year('an_inmatriculare')->nullable()->default(NULL);
            $table->integer('an_studiu')->nullable()->default(NULL);

            $table->string('data_nastere')->nullable()->default(NULL);
            //check this
            $table->integer('tip_act_identitate_id')->nullable()->default(NULL);
            $table->string('cnp')->nullable()->default(NULL);
            $table->string('numar_serie')->nullable()->default(NULL);
            $table->string('telefon')->nullable()->default(NULL);

            $table->string('email')->unique()->nullable()->default(NULL);
            $table->string('password');
            $table->rememberToken();

            $table->string('web')->nullable()->default(NULL);
            $table->string('prenume_tata')->nullable()->default(NULL);
            $table->string('prenume_mama')->nullable()->default(NULL);
            $table->string('nume_casatorie')->nullable()->default(NULL);
            $table->string('titlu_teza')->nullable()->default(NULL);


            $table->text('comisie')->nullable()->default(NULL);
            $table->text('adresa')->nullable()->default(NULL);
            $table->integer('tip_cetatenie_id')->nullable()->default(NULL);
            $table->integer('a_doua_cetatenie_id')->nullable()->default(NULL);
            $table->string('sex')->nullable()->default(NULL);
            $table->integer('tip_banca_id')->nullable()->default(NULL);
            $table->string('cont_banca')->nullable()->default(NULL);
            $table->integer('venit_pe_familie')->nullable()->default(NULL);
            $table->string('alte_venituri')->nullable()->default(NULL);
            $table->string('nume_liceu_absolvit')->nullable()->default(NULL);
            $table->float('nota_bacalaureat')->nullable()->default(NULL);
            $table->integer('localitate_domiciliu_id')->nullable()->default(NULL);
            $table->integer('judet_domiciliu_id')->nullable()->default(NULL);
            $table->integer('judet_nastere_id')->nullable()->default(NULL);
            $table->integer('localitate_nastere_id')->nullable()->default(NULL);
            $table->integer('orfan_de_un_parinte')->nullable()->default(NULL);
            $table->string('numar_matricol')->nullable()->default(NULL);
            $table->string('tip_act_identitate')->nullable()->default(NULL);
            $table->string('numar_legitimatie')->nullable()->default(NULL);

            $table->string('utilizator_id')->nullable()->default(NULL);
            $table->string('status')->nullable()->default(NULL);
            $table->string('dmy_facultate')->nullable()->default(NULL);
            $table->string('dmy_domeniu')->nullable()->default(NULL);
            $table->string('dmy_grupa')->nullable()->default(NULL);
            $table->string('dmy_taxa')->nullable()->default(NULL);
            $table->string('dmy_anstudiu')->nullable()->default(NULL);
            $table->string('dmy_anuniv')->nullable()->default(NULL);
            $table->integer('dmy_org_unit_id_pk')->nullable()->default(NULL);
            //
            $table->integer('portal_id')->nullable()->default(NULL);
            $table->integer('moodle_user_id')->nullable()->default(NULL);
            $table->string('moodle_id_number')->nullable()->default(NULL);
            $table->string('moodle_username')->nullable()->default(NULL);
            $table->integer('user_id')->nullable()->default(NULL);
            $table->string('parola_initiala')->nullable()->default(NULL);
            //
            $table->string('observatii_student')->nullable()->default(NULL);
            $table->integer('candidat_facultate_admitere_id')->nullable()->default(NULL);
            $table->float('medie_admitere')->nullable()->default(NULL);
            $table->string('an_emitere_diploma_facultate')->nullable()->default(NULL);
            $table->string('profil_liceu')->nullable()->default(NULL);
            $table->string('serie_diploma_facultate')->nullable()->default(NULL);
            $table->string('numar_diploma_facultate')->nullable()->default(NULL);
            $table->string('forma_finantare_facultare')->nullable()->default(NULL);
            $table->string('an_absolvire_master')->nullable()->default(NULL);
            $table->string('durata_studii_facultate_master')->nullable()->default(NULL);
            $table->string('an_emitere_diploma_master')->nullable()->default(NULL);
            $table->string('program_specializare_facultate_master')->nullable()->default(NULL);
            $table->string('forma_finantate_facultate_master')->nullable()->default(NULL);
            $table->string('nr_ani_bugetati_master')->nullable()->default(NULL);
            $table->string('strada_domiciliu')->nullable()->default(NULL);
            $table->string('nr_strada_domiciliu')->nullable()->default(NULL);
            $table->string('bloc_domiciliu')->nullable()->default(NULL);
            $table->string('apartament_domiciliu')->nullable()->default(NULL);
            $table->string('cod_postal_domiciliu')->nullable()->default(NULL);
            $table->string('program_specializare_facultate')->nullable()->default(NULL);
            $table->string('nr_diploma_facultate_master')->nullable()->default(NULL);

            $table->boolean('persoana_cu_dizabilitati')->default(0);

            $table->integer('tara_liceu_id')->nullable()->default(NULL);
            $table->integer('tara_domiciliu_id')->nullable()->default(NULL);
            $table->integer('durata_studii_facultate')->nullable()->default(NULL);
            $table->integer('facultate_absolvita_id')->nullable()->default(NULL);
            $table->integer('nr_ani_bugetati_licenta')->nullable()->default(NULL);
            $table->integer('tara_facultate_master_id')->nullable()->default(NULL);
            $table->integer('judet_facultate_master_id')->nullable()->default(NULL);
            $table->integer('localitate_facultate_master_id')->nullable()->default(NULL);
            $table->integer('universitate_master_id')->nullable()->default(NULL);
            $table->integer('tara_nastere_id')->nullable()->default(NULL);

            $table->integer('liceu_absolvit_id')->nullable()->default(NULL);
            $table->integer('localitate_liceu_absolvit_id')->nullable()->default(NULL);
            $table->integer('judet_liceu_absolvit_id')->nullable()->default(NULL);
            $table->string('an_absolvire_liceu')->nullable()->default(NULL);
            $table->string('forma_inv_liceu_absolvit')->nullable()->default(NULL);
            $table->string('act_identitate_serie')->nullable()->default(NULL);
            $table->string('act_identitate_numar')->nullable()->default(NULL);
            $table->string('eliberat_de')->nullable()->default(NULL);
            $table->string('eliberat_data')->nullable()->default(NULL);
            $table->string('etnia')->nullable()->default(NULL);
            $table->string('valabilitate_pana_la')->nullable()->default(NULL);
            $table->integer('erasmus')->nullable()->default(NULL);
            $table->integer('localitate_populatie_mica')->nullable()->default(NULL);
            $table->integer('urban')->nullable()->default(NULL);
            $table->integer('rural')->nullable()->default(NULL);
            $table->integer('maturi')->nullable()->default(NULL);
            $table->string('studii_liceu_id_forma_invatamant')->nullable()->default(NULL);
            $table->string('date_diploma_seria')->nullable()->default(NULL);
            $table->string('numar_diploma_bac')->nullable()->default(NULL);
            $table->string('date_diploma_anul')->nullable()->default(NULL);
            $table->string('alte_observatii')->nullable()->default(NULL);
            $table->string('date_diploma_emitent_id')->nullable()->default(NULL);
            $table->string('stare_sociala_speciala_id')->nullable()->default(NULL);
            $table->integer('judet_facultate_absolvita_id')->nullable()->default(NULL);
            $table->integer('tara_facultate_absolvita_id')->nullable()->default(NULL);
            $table->string('localitate_facultate_absolvita_id')->nullable()->default(NULL);
            $table->string('forma_invatamant_facultate_absolvita')->nullable()->default(NULL);
            $table->integer('universitate_absolvita_id')->nullable()->default(NULL);
            $table->string('an_absolvire_facultate')->nullable()->default(NULL);
            $table->string('situatie_medicala_speciala_id')->nullable()->default(NULL);
            $table->integer('n_liceu_id')->nullable()->default(NULL);
            $table->integer('date_diploma_localitate_emitent_id')->nullable()->default(NULL);
            $table->integer('date_diploma_judet_emitent_id')->nullable()->default(NULL);
            $table->string('sn_pasaport_strain')->nullable()->default(NULL);
            $table->string('denumire_liceu_absolvit_strain')->nullable()->default(NULL);
            $table->string('specializare_liceu_absolvit_strain')->nullable()->default(NULL);
            $table->string('date_diploma_localitate_strainatate')->nullable()->default(NULL);
            $table->string('an_sesiune_bac')->nullable()->default(NULL);
            $table->string('localitate_liceu_absolvit_strain')->nullable()->default(NULL);
            $table->integer('studii_liceu_id_n_specializare')->nullable()->default(NULL);
            $table->integer('are_cnp')->nullable()->default(NULL);
            $table->integer('student_strain')->nullable()->default(NULL);
            $table->string('adresa_numar')->nullable()->default(NULL);
            $table->string('localitate_nastere_strainatate')->nullable()->default(NULL);
            $table->string('localitate_domiciliu_strainatate')->nullable()->default(NULL);
            $table->string('liceu_institutie')->nullable()->default(NULL);
            $table->string('liceu_institutie_eminenta')->nullable()->default(NULL);
            $table->integer('candidat_olimpic')->nullable()->default(NULL);
            $table->integer('admis')->nullable()->default(0);
            $table->integer('respins')->nullable()->default(0);
            $table->integer('conducator_doctorat_id')->nullable()->default(NULL);
            $table->integer('limba_id')->nullable()->default(NULL);
            $table->integer('nationalitate_id')->nullable()->default(NULL);
            $table->integer('forma_invatamant_id')->nullable()->default(NULL);
            $table->integer('forma_admitere_id')->nullable()->default(NULL);
            $table->integer('etnia_id')->nullable()->default(NULL);
            $table->integer('localitate_facultate_id')->nullable()->default(NULL);

            $table->string('nota_disertatie')->nullable()->default('0.00');
            $table->string('medie_licenta')->nullable()->default('0.00');
            $table->string('medie_ani_studiu_licenta')->nullable()->default('0.00');
            $table->string('medie_ani_studiu_master')->nullable()->default('0.00');
            $table->integer('fost_student')->nullable()->default(0);
            $table->integer('absolvent')->nullable()->default(0);
            $table->integer('student_nr_ani_bugetat')->nullable()->default(0);
            $table->integer('absolvent_nr_ani_bugetat')->nullable()->default(0);

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('students');
    }
}

And here are the errors: click

I'm using Laravel 7 + MySQL.

  • No individual field is too big -- but the sum of all them together is. You'll have to make a bunch of the fields smaller (so the total is under 64k) or split into multiple tables. – Alex Howansky Mar 25 '21 at 23:49
  • 1
    Your table design is awful. Why is 'data_nastere' (date of birth) set as varchar(255)? That should be a `DATE` or `DATETIME` column. Is `utilizator_id` really 255 characters long? I doubt it. The 'people' are right. Your fields are too long, or use the wrong type, or both. – Tangentially Perpendicular Mar 26 '21 at 00:06
  • Way too many fields, few correct field types, this thing is a mess. – miken32 Mar 26 '21 at 03:27
  • 1
    Start with few fields, then keep adding more fields until you again encounter this error. Maybe that gives more insight on what is going wrong. – maverickm Mar 26 '21 at 14:23

3 Answers3

-1

In my mysql/maridb when this happens the fix is to make the row_format= dynamic.

Try this if it's either db.

ALTER TABLE your_table ROW_FORMAT=DYNAMIC;

More here https://mariadb.com/kb/en/troubleshooting-row-size-too-large-errors-with-innodb/

Fact
  • 1,957
  • 1
  • 17
  • 26
-1

instead of $table->string('an_sesiune_bac') you can define your column size such
$table->string('an_sesiune_bac',columnsize) this will avoid the size to be the default value '255'

-2

You have to devide your table to multiple tables. And connect it each other with relation. And you can use Laravel relations hasOne and belongsTo. For ex:

users
id
username
name

students
id
user_id
cart_number
...

user_address
id
user_id
address
street
...

And change data types to correct value

Farhod Nematov
  • 470
  • 2
  • 8
  • The OP doesn't have to divide his table at all. Take a look at the table definition. It is riddled with incorrect data types and excessive space allocations. What's required is a table definition that makes some sense. – Tangentially Perpendicular Mar 28 '21 at 00:10
  • There is a problem not with data types. Problem with table columns count. If he devide table will solve the problem. Other users wrote about data type that's way I didn't write about it. – Farhod Nematov Mar 28 '21 at 15:11