<?php
 use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use ModStart\Core\Dao\ModelManageUtil; class CreateNews extends Migration { public function up() { if (ModelManageUtil::hasTable('news')) { $columns = ModelManageUtil::listTableColumns('news'); if (!in_array('categoryId', $columns)) { Schema::table('news', function (Blueprint $table) { $table->integer('categoryId')->nullable()->comment(''); }); } if (!in_array('cover', $columns)) { Schema::table('news', function (Blueprint $table) { $table->string('cover', 200)->nullable()->comment(''); }); } if (!in_array('summary', $columns)) { Schema::table('news', function (Blueprint $table) { $table->string('summary', 200)->nullable()->comment(''); }); } } else { Schema::create('news', function (Blueprint $table) { $table->increments('id'); $table->timestamps(); $table->integer('categoryId')->nullable()->comment(''); $table->string('title', 200)->nullable()->comment(''); $table->string('cover', 200)->nullable()->comment(''); $table->string('summary', 200)->nullable()->comment(''); $table->text('content')->nullable()->comment(''); }); } } public function down() { } } 