我的 php artisan 迁移发生了什么

what's happened with my php artisan migrate

[Illuminate\Database\QueryException] SQLSTATE[42000]:语法错误或访问冲突:1064 你有一个错误我 n 你的 SQL 语法;查看与您的 MySQL 服务器 v 相对应的手册 ersion 用于在更新 casc 上删除级联时使用 near ') 的正确语法 ade' 在第 1 行 (SQL: alter table users add constraint users_address_id_fo reign 外键 (address_id) 引用 address () on delete cascade 更新级联)

[PDOException] SQLSTATE[42000]:语法错误或访问冲突:1064 你有一个错误我 n 你的 SQL 语法;查看与您的 MySQL 服务器 v 相对应的手册 ersion 用于在更新 casc 上删除级联时使用 near ') 的正确语法 ade' 在第 1 行

迁移 [--bench[="..."]] [--数据库[="..."]] [--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');
            });

        }

您的语法有误。您正在使用 reference() 方法,但正确的方法是 references()。修复它,我想一​​切都会好的。