<?php
 use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; use ModStart\Core\Dao\ModelManageUtil; class CreateNav extends Migration { public function up() { if (ModelManageUtil::hasTable('nav')) { $columns = ModelManageUtil::listTableColumns('nav'); if (!in_array('position', $columns)) { if (in_array('type', $columns)) { Schema::table('nav', function (Blueprint $table) { $table->renameColumn('type', 'position'); }); } } if (!in_array('name', $columns)) { if (in_array('title', $columns)) { Schema::table('nav', function (Blueprint $table) { $table->renameColumn('title', 'name'); }); } } if (!in_array('link', $columns)) { if (in_array('url', $columns)) { Schema::table('nav', function (Blueprint $table) { $table->renameColumn('url', 'link'); }); } } } else { Schema::create('nav', function (Blueprint $table) { $table->increments('id'); $table->timestamps(); $table->string('position', 50)->nullable()->comment('位置'); $table->integer('sort')->nullable()->comment('顺序'); $table->string('name', 100)->nullable()->comment('图片'); $table->string('link', 200)->nullable()->comment('链接'); }); } } public function down() { } }