Skip to content

Commit e2d4698

Browse files
committed
adding migration files
1 parent 4db392e commit e2d4698

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class Posts extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('posts', function (Blueprint $table) {
17+
$table->id();
18+
$table->unsignedBigInteger('user_id');
19+
$table->foreign('user_id')
20+
->references('id')->on('users')
21+
->onDelete('cascade');
22+
$table->string('title')->unique();
23+
$table->text('body');
24+
$table->text('metaDescription');
25+
$table->string('metaTitle');
26+
$table->string('slug')->unique();
27+
$table->boolean('active');
28+
$table->timestamps();
29+
});
30+
}
31+
32+
/**
33+
* Reverse the migrations.
34+
*
35+
* @return void
36+
*/
37+
public function down()
38+
{
39+
Schema::drop('posts');
40+
}
41+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
class Comments extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('comments', function (Blueprint $table) {
17+
$table->id();
18+
$table->unsignedBigInteger('post_id');
19+
$table->unsignedBigInteger('user_id');
20+
$table->foreign('post_id')
21+
->references('id')->on('posts')
22+
->onDelete('cascade');
23+
$table->foreign('user_id')
24+
->references('id')->on('users')
25+
->onDelete('cascade');
26+
$table->text('comment');
27+
$table->timestamps();
28+
});
29+
}
30+
31+
/**
32+
* Reverse the migrations.
33+
*
34+
* @return void
35+
*/
36+
public function down()
37+
{
38+
Schema::drop('comments');
39+
}
40+
}

0 commit comments

Comments
 (0)