Click here to Skip to main content
15,435,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem in the migration code so when I try to use artisan migrate it s doesn't work and gives me errors

What I have tried:

So This is the Migration
PHP
id();
            $table->string('Personne');
            $table->string('Nom_F');
            $table->string('Nom_A');
            $table->string('Cni');
            $table->string('Secteur');
            $table->string('Fjuridique');
            $table->string('Activite');
            $table->string('Membre');
            $table->string('Adherant');
            $table->string('Patente');
            $table->string('R.C_Analytique');
            $table->string('R.C_Chronologique');
            $table->date('dateRc');
            $table->string('ice');
            $table->string('Identification_Fiscale');
            $table->date('dateIDF');
            $table->string('Address');
            $table->string('commune');
            $table->string('tele');
            $table->string('Gsm');
            $table->string('Fax');
            $table->string('email');
            $table->string('site');

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

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


An this is the error after the command

λ php artisan migrate

   INFO  Running migrations.

  2022_08_01_124125_create_ressos_table .................................................................. 4ms FAIL

   Illuminate\Database\QueryException

  SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.`C_Analytique` varchar(191) not null, `R`.`C_Chronologique` varchar(191) not nu' at line 1 (SQL: create table `ressos` (`id` bigint unsigned not null auto_increment primary key, `Personne` varchar(191) not null, `Nom_F` varchar(191) not null, `Nom_A` varchar(191) not null, `Cni` varchar(191) not null, `Secteur` varchar(191) not null, `Fjuridique` varchar(191) not null, `Activite` varchar(191) not null, `Membre` varchar(191) not null, `Adherant` varchar(191) not null, `Patente` varchar(191) not null, `R`.`C_Analytique` varchar(191) not null, `R`.`C_Chronologique` varchar(191) not null, `dateRc` date not null, `ice` varchar(191) not null, `Identification_Fiscale` varchar(191) not null, `dateIDF` date not null, `Address` varchar(191) not null, `commune` varchar(191) not null, `tele` varchar(191) not null, `Gsm` varchar(191) not null, `Fax` varchar(191) not null, `email` varchar(191) not null, `site` varchar(191) not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

  at C:\laragon\www\cista\vendor\laravel\framework\src\Illuminate\Database\Connection.php:759
    755▕         // If an exception occurs when attempting to run a query, we'll format the error
    756▕         // message to include the bindings with SQL, which will make this exception a
    757▕         // lot more helpful to the developer instead of just the database's errors.
    758▕         catch (Exception $e) {
  ➜ 759▕             throw new QueryException(
    760▕                 $query, $this->prepareBindings($bindings), $e
    761▕             );
    762▕         }
    763▕     }

  1   C:\laragon\www\cista\vendor\laravel\framework\src\Illuminate\Database\Connection.php:538
      PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.`C_Analytique` varchar(191) not null, `R`.`C_Chronologique` varchar(191) not nu' at line 1")

  2   C:\laragon\www\cista\vendor\laravel\framework\src\Illuminate\Database\Connection.php:538
      PDO::prepare("create table `ressos` (`id` bigint unsigned not null auto_increment primary key, `Personne` varchar(191) not null, `Nom_F` varchar(191) not null, `Nom_A` varchar(191) not null, `Cni` varchar(191) not null, `Secteur` varchar(191) not null, `Fjuridique` varchar(191) not null, `Activite` varchar(191) not null, `Membre` varchar(191) not null, `Adherant` varchar(191) not null, `Patente` varchar(191) not null, `R`.`C_Analytique` varchar(191) not null, `R`.`C_Chronologique` varchar(191) not null, `dateRc` date not null, `ice` varchar(191) not null, `Identification_Fiscale` varchar(191) not null, `dateIDF` date not null, `Address` varchar(191) not null, `commune` varchar(191) not null, `tele` varchar(191) not null, `Gsm` varchar(191) not null, `Fax` varchar(191) not null, `email` varchar(191) not null, `site` varchar(191) not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci'")
Posted
Comments
Richard Deeming 2-Aug-22 6:02am    
Looks like the problem is caused by column names with a "." in them. Try sticking to regular column names, without any special characters.
Achraf Serroukh 2-Aug-22 6:04am    
Thank you so much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900