Skip to content

Commit

Permalink
Merge pull request #3 from ctrl-alt-d/patch-1
Browse files Browse the repository at this point in the history
Create unique index for fast retrieve from url_key
  • Loading branch information
magarrent committed Aug 13, 2021
2 parents 07d331d + fcd0251 commit f855d1b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions database/migrations/2021_08_12_165626_addunique_url_key.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AdduniqueUrlKey extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('url_shorteners', function (Blueprint $table) {
$table->unique('url_key');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('url_shorteners', function (Blueprint $table) {
$table->dropUnique('url_key');
});
}
}

0 comments on commit f855d1b

Please sign in to comment.