[Illuminate \ Database \ QueryException] SQLSTATE [42000]: Синтаксическая ошибка или нарушение доступа: 1064 У вас есть ошибка i n ваш синтаксис SQL; проверьте руководство, соответствующее вашему серверу MySQL, v ersion для правильного синтаксиса для использования рядом ') при удалении cascade при обновлении casc ade' в строке 1 (SQL: изменить таблицу users
добавить ограничение users_address_id_fo изменить внешний ключ (address_id
) ссылки address
() при удалении каскада на обновление каскада)Что случилось с моим php artisan migrate
[PDOException] SQLSTATE [42000]: ошибка синтаксиса или нарушение прав доступа: 1064 у вас ошибка я п синтаксис SQL; проверьте руководство, которое соответствует вашему серверу MySQL против ersion для правильного синтаксиса использовать вблизи «) при удалении каскада на обновление CASC ADE» в строке 1
мигрирует [--bench [= «...»] ] [--database [= "..."]] [--force] [--path [= "..."]] [--pac kage [= "..."]] [- притвориться] [--seed]
public function up()
{
Schema::create('users',function($table){
$table->increments('id');
$table->string('name',30);
$table->string('phone',11);
$table->integer('age');
$table->string('email',50);
$table->string('marry_status',10);
$table->integer('address_id');
$table->foreign('address_id')->reference('id')->on('address')->onDelete('cascade')->onUpdate('cascade');
$table->integer('points_id');
$table->foreign('points_id')->reference('id')->on('address')->onDelete('cascade')->onUpdate('cascade');
$table->timestamps();
});
}
PHP мигрирует --pretend
CreateUsersTable: create table `users` (`id` int unsigned not null auto_increment primary key, `name` varchar(30) not null, `phone` varchar(11) not null, `age` int not null, `email` varchar(50) not null, `marry_status` varchar(10) not null, `address_id` int not null, `points_id` int not null, `created_at` timestamp default 0 not null, `updated_at` timestamp default 0 not null) default character set utf8 collate utf8_unicode_ci
CreateUsersTable: alter table `users` add constraint users_address_id_foreign foreign key (`address_id`) references `address`() on delete cascade on update cascade
CreateUsersTable: alter table `users` add constraint users_points_id_foreign foreign key (`points_id`) references `address`() on delete cascade on update cascade
CreateAddressTable: create table `address` (`id` int unsigned not null auto_increment primary key, `users_id` int not null, `name` varchar(30) not null, `created_at` timestamp default 0 not null, `updated_at` timestamp default 0 not null) default character set utf8 collate utf8_unicode_ci
CreatePointsTable: create table `points` (`id` int unsigned not null auto_increment primary key, `point` int not null, `users_id` int not null, `created_at` timestamp default 0 not null, `updated_at` timestamp default 0 not null) default character set utf8 collate utf8_unicode_ci
я попробовать, но я не очень хорошо
public function up()
{
Schema::create('users',function($table){
$table->increments('id');
$table->string('name',30);
$table->string('phone',11);
$table->integer('age');
$table->string('email',50);
$table->string('marry_status',10);
$table->integer('address_id');
$table->integer('points_id');
$table->timestamps();
});
Schema::table('users',function($table){
$table->foreign('points_id')->references('id')->on('address')->onDelete('cascade')->onUpdate('cascade');
$table->foreign('address_id')->references('id')->on('address')->onDelete('cascade')->onUpdate('cascade');
});
}
Запустите команду 'migrate' с флагом' --pretend' и покажите нам результат. –
@anh У вас есть ** ссылка ** под вашим вопросом, используйте его, чтобы изменить вопрос и включить вывод команды там, не публикуйте эту информацию в комментариях. – Bogdan
Обновите пожалуйста свой вопрос с этим выходом. Это будет более читаемо. –