Laravel Sqlite migrate error

Asked

Viewed 26 times

0

When running the Migrate command it gives this error: inserir a descrição da imagem aqui

code of the first migrate:

` public function up()
    {
        Schema::create('contatos', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('nome');
            $table->string('tel');
            $table->string('email');
            $table->bigIncrements('id');

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

Segunda migrate:

`public function up()
    {
        Schema::create('produtos', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('titulo');
            $table->string('descricao');
            $table->decimal('valor',5,2);
            $table->bigIncrements('id');

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

1 answer

0


In both methods you are trying to create the id column twice, one at the beginning and one at the end, two columns with the same name are not allowed in a table.

Try to perform the execution this way:

public function up()
{
   Schema::create('contatos', function (Blueprint $table) {
      $table->bigIncrements('id');
      $table->string('nome');
      $table->string('tel');
      $table->string('email');
      $table->timestamps();
   });
}

public function up()
{
   Schema::create('produtos', function (Blueprint $table) {
      $table->bigIncrements('id');
      $table->string('titulo');
      $table->string('descricao');
      $table->decimal('valor',5,2);
      $table->timestamps();
   });
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.