Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

indexing in database laravel

Schema::create('comments', function (Blueprint $table) {
    $table->increments('id');

    //column we want as an index
    $table->integer('post_id')->unsigned();
    //defining the index
    $table->foreign('post_id')->references('id')->on('posts')
        ->onDelete('cascade');

    $table->string("comment");
    $table->timestamps();
});
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #indexing #database #laravel
ADD COMMENT
Topic
Name
5+5 =