0

Ao rodar a migrate aqui, o laravel está retornando:

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

Segue em anexo o código que estou usando para criar a migration:

 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();
        });

1 Resposta 1

0

Isso acontece por que o segundo parâmetro das colunas do tipo "integer" é a flag de $autoincrement e não o tamanho da coluna. Tente alterar

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

para

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

https://github.com/laravel/framework/blob/330d11ba8cd3d6c0a54a1125943526b126147b5f/src/Illuminate/Database/Schema/Blueprint.php#L443

Na minha opnião, uma coluna que recebe número de telefone deve ser do tipo character varying, por não ser uma foreign key, coluna do tipo auto-increment e/ou uma index.

2
  • Esqueci de colocar resolvido. Mas era isto msm. Eu uso como varchar :D. Sem querer coloquei o integer. Estou aprendendo mexer com Laravel. 19/07/2016 às 18:07
  • Ótimo, que bom que conseguiu resolver o seu problema. Bom aprendizado, abraços. 19/07/2016 às 22:59

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .