Laravel returns Incorrect table definition;

0

While running the migrate here, laravel is returning:

  

Incorrect table definition; there can be only one auto column and it   should be defined as a key.

The code I am using to create the migration is attached:

 Schema::create('pessoas', function (Blueprint $table) {
            $table->increments('id');
            $table->string('nome',120);
            $table->string('tipopessoa',20);
            $table->string('nomefantasia',120)->nullable();
            $table->string('cpfcnpj',20)->nullable();
            $table->string('insc_est',25)->nullable();
            $table->string('insc_munic',25)->nullable();
            $table->date('datanasc')->nullable();
            $table->string('sexo',1)->nullable();
            $table->string('logradouro',100)->nullable();
            $table->string('numero_lograd',10)->nullable();
            $table->string('comple_lograd',80)->nullable();
            $table->string('bairro_lograd',40)->nullable();
            $table->integer('cod_munic')->nullable();
            $table->string('cep_lograd',10)->nullable();
            $table->string('fone',15)->nullable();
            $table->string('fax',15)->nullable();
            $table->string('email',50)->nullable();
            $table->string('site',50)->nullable();
            $table->integer('codusuacad')->nullable();
            $table->integer('celular',15)->nullable();
            $table->string('uf',10)->nullable();
            $table->integer('codusuaalt')->nullable();
            $table->string('insc_isento',50)->nullable();
            $table->string('logradouro_cor',100)->nullable();
            $table->string('comple_lograd_cor',80)->nullable();
            $table->string('bairro_lograd_cor',40)->nullable();
            $table->integer('cod_munic_cor')->nullable();
            $table->string('uf_cor',10)->nullable();
            $table->string('nome_pai',100)->nullable();
            $table->string('nome_mae',100)->nullable();
            $table->string('numero_pis',25)->nullable();
            $table->string('numero_ctps',25)->nullable();
            $table->string('cep_lograd_cor',10)->nullable();
            $table->string('endereco_cor',120)->nullable();
            $table->string('banco',60)->nullable();
            $table->string('agencia',40)->nullable();
            $table->string('conta',40)->nullable();
            $table->string('operacao',10)->nullable();
            $table->string('nacionalidade',60)->nullable();
            $table->string('naturalidade',60)->nullable();
            $table->string('necessidade_esp',60)->nullable();
            $table->string('deficiencia',60)->nullable();
            $table->date('emissao_rg')->nullable();
            $table->string('uf_rg',2)->nullable();
            $table->string('num_crc',20)->nullable();
            $table->date('emissao_crc')->nullable();
            $table->date('validade_crc')->nullable();
            $table->string('uf_crc')->nullable();
            $table->string('num_titulo')->nullable();
            $table->string('zona_titulo')->nullable();
            $table->string('secao_titulo')->nullable();
            $table->date('emissao_titulo')->nullable();
            $table->integer('municipio_id');
            $table->string('num_cnh')->nullable();
            $table->date('validade_cnh')->nullable();
            $table->date('primeira_cnh')->nullable();
            $table->string('uf_cnh')->nullable();
            $table->string('categoria_cnh')->nullable();
            $table->string('serie_ctps')->nullable();
            $table->string('uf_ctps')->nullable();
            $table->string('estado_civil')->nullable();
            $table->string('grau_instrucao')->nullable();
            $table->string('raca_cor')->nullable();
            $table->string('tipo_habitacao')->nullable();
            $table->integer('dependente')->nullable();
            $table->integer('nacionalidade_cod')->nullable();
            $table->integer('grau_instrucao_cod')->nullable();
            $table->integer('raca_cor_cod')->nullable();
            $table->integer('deficiencia_cod')->nullable();
            $table->integer('envportal')->nullable();
            $table->timestamps();
        });
    
asked by anonymous 19.07.2016 / 14:35

1 answer

0

This happens because the second parameter of the integer columns is the $ autoincrement flag and not the column size. Try changing

$table->integer('celular',15)->nullable();

for

$table->integer('celular')->nullable();

link

In my opinion, a column that receives a telephone number must be of type character varying , because it is not a foreign key , a column of type auto-increment and / or a index .

    
19.07.2016 / 19:25