🗃️ Ajoute les tags

Pour #1
This commit is contained in:
2019-09-30 16:31:16 +02:00
parent 333f6feafb
commit a7715c8460
5 changed files with 96 additions and 1 deletions

View File

@@ -0,0 +1,42 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTags extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tags', function (Blueprint $table) {
$table->bigIncrements('id');
$table->timestamps();
$table->string('name')->unique();
});
Schema::create('posts_tags', function (Blueprint $table) {
$table->bigIncrements('id');
$table->timestamps();
$table->bigInteger('post_id');
$table->bigInteger('tag_id');
$table->foreign('post_id')->references('id')->on('posts');
$table->foreign('tag_id')->references('id')->on('tags');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tags');
Schema::dropIfExists('posts_tags');
}
}