首页 > 其他 > 详细

laravel 外键schema

时间:2015-10-27 11:17:49      阅读:251      评论:0      收藏:0      [点我收藏+]

$table->bigIncrements(‘id‘)  ;   Incrementing ID (primary key) using a " UNSIGNED BIG INTEGER" equivalent.

$table->increments(‘id‘)

$table->smallIncrements(‘id‘)

        Schema::create(‘roles‘, function (Blueprint $table) {
            $table->tinyInteger(‘id‘)->unsigned()->autoIncrement();
            $table->string(‘name‘);
            $table->string(‘display_name‘);
        });

        Schema::create(‘permissions‘, function (Blueprint $table) {
            $table->smallIncrements(‘id‘);
            $table->string(‘name‘);
            $table->string(‘display_name‘);
        });

        Schema::create(‘permission_role‘, function (Blueprint $table) {
            $table->smallInteger(‘permission_id‘)->unsigned();
            $table->tinyInteger(‘role_id‘)->unsigned();
            $table->foreign(‘permission_id‘)->references(‘id‘)->on(‘permissions‘)->onDelete(‘cascade‘);
            $table->foreign(‘role_id‘)->references(‘id‘)->on(‘roles‘)->onDelete(‘cascade‘);
        });

 

laravel 外键schema

原文:http://www.cnblogs.com/fenle/p/4913333.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!