📜  外键 cosntraint laravel - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:27.043000             🧑  作者: Mango

代码示例1
public function up()
{
    Schema::create('priorities', function($table) {
        $table->increments('id', true);
        $table->integer('user_id')->unsigned();
        $table->string('priority_name');
        $table->smallInteger('rank');
        $table->text('class');
        $table->timestamps('timecreated');
    });

   Schema::table('priorities', function($table) {
       $table->foreign('user_id')->references('id')->on('users');
   });

}