zoukankan      html  css  js  c++  java
  • 使用laravel 的artisan快速创建表

    参考:使用laravel 的artisan快速创建表

    字段类型参考链接: 结构生成器

    版本: Laravel 4.2

    1. 创建migrate 文件

    php artisan migrate:make create_lang_table

    2. 编辑migrate文件

    <?php
    
    use IlluminateDatabaseSchemaBlueprint;
    use IlluminateDatabaseMigrationsMigration;
    
    class CreateLangTable extends Migration {
    
        /**
         * Run the migrations.
         *
         * @return void
         */
        public function up()
        {
            //
            Schema::create('lang', function(Blueprint $table)
            {
                $table->increments('id');//主键自增
                $table->string('local',50); //语言
                $table->string('title',30); //标题
                $table->tinyInteger('main')->nullable(); //主要语言
                $table->tinyInteger('published')->default(1); //发布
                $table->integer('ordering')->default(0); //排序
                $table->timestamps();
            });
        }
    
        /**
         * Reverse the migrations.
         *
         * @return void
         */
        public function down()
        {
            //
        }
    
    }

    3. 创建表

    1 php artisan migrate

    就会看到类似的信息:

    1 vagrant@precise32:/var/www/html$ php artisan migrate
    2 **************************************
    3 *     Application In Production!     *
    4 **************************************
    5 
    6 Do you really wish to run this command? yes
    7 Migrated: 2015_11_01_114540_create_lang_table
  • 相关阅读:
    C++中的类模板详细讲述
    函数模板和模板函数
    vs2008 快捷键大全
    #宏定义##
    多工程项目设置
    conemu 配置
    itcast-svn
    itcast-spring-三大框架整合
    Spring通知方法错误
    动态代理
  • 原文地址:https://www.cnblogs.com/fsong/p/4927439.html
Copyright © 2011-2022 走看看