Last change
on this file was 0924b6c, checked in by Özkan İliyaz <iliyaz_96@…>, 4 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[0924b6c] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | use Illuminate\Support\Facades\Schema;
|
---|
| 4 | use Illuminate\Database\Schema\Blueprint;
|
---|
| 5 | use Illuminate\Database\Migrations\Migration;
|
---|
| 6 |
|
---|
| 7 | class CreatePostsTable 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->increments('id');
|
---|
| 18 | $table->integer("user_id")->unsigned();
|
---|
| 19 | $table->integer("category_id")->unsigned();
|
---|
| 20 | $table->integer("confirmed_by")->unsigned()->nullable();
|
---|
| 21 | $table->string("title");
|
---|
| 22 | $table->string("image_link");
|
---|
| 23 | $table->text("content");
|
---|
| 24 | $table->string("slug")->unique();
|
---|
| 25 | $table->integer("total_likes")->default(0);
|
---|
| 26 | $table->boolean("is_active")->default(false);
|
---|
| 27 | $table->boolean("is_confirmed")->default(false);
|
---|
| 28 | $table->timestamps();
|
---|
| 29 |
|
---|
| 30 | $table->foreign("user_id")->references("id")->on("users")->onDelete("cascade")->onUpdate("cascade");
|
---|
| 31 | $table->foreign("confirmed_by")->references("id")->on("users")->onDelete("cascade")->onUpdate("cascade");
|
---|
| 32 | $table->foreign("category_id")->references("id")->on("categories")->onDelete("cascade")->onUpdate("cascade");
|
---|
| 33 | });
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | /**
|
---|
| 37 | * Reverse the migrations.
|
---|
| 38 | *
|
---|
| 39 | * @return void
|
---|
| 40 | */
|
---|
| 41 | public function down()
|
---|
| 42 | {
|
---|
| 43 | Schema::dropIfExists('posts');
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.