44 lines
1001 B
PHP
Executable File
44 lines
1001 B
PHP
Executable File
<?php
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
class CreatePostTable extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function up()
|
|
{
|
|
Schema::create('posts', function (Blueprint $table) {
|
|
$table->increments('id');
|
|
$table->string('type', 100);
|
|
$table->string('title', 255);
|
|
$table->string('slug')->nullable();
|
|
$table->text('content');
|
|
$table->dateTime('datetime')->nullable();
|
|
$table->integer('user_id')->unsigned()->nullable();
|
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('SET NULL');
|
|
$table->timestamps();
|
|
$table->softDeletes();
|
|
$table->boolean('published');
|
|
});
|
|
|
|
DB::statement('ALTER TABLE posts ADD FULLTEXT fulltext_index (type, title, content)');
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function down()
|
|
{
|
|
Schema::dropIfExists('posts');
|
|
}
|
|
}
|