插件简介

该插件主要实现了SQL转换为Laravel数据库迁移类,加快开发速度。

授权:需要授权

作者:mycms

版本:v1.0.0

标识:UrlFormat

转换示例

CREATE TABLE `my_article` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `category_id` int(11) NOT NULL DEFAULT '0',
  `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `img` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `author` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `content` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

 

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateMyArticleTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('my_article', function (Blueprint $table) {
            $table->bigInteger("id",true,true);
            $table->string("title",255);
            $table->integer("category_id",false,false)->default(0);
            $table->string("description",255)->default(NULL)->nullable();
            $table->string("img",255)->default(NULL)->nullable();
            $table->string("author",255)->default(NULL)->nullable();
            $table->text("content");
            $table->timestamp("created_at")->default(NULL)->nullable();
            $table->timestamp("updated_at")->default(NULL)->nullable();
            
            $table->engine = "InnoDB";
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('my_article');
    }
}