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
  • 相关阅读:
    ansible
    celery 计划任务使用
    11 session 使用
    10 模版继承和页面之间的调用
    9 模版语言 jinja2
    8 公共函数
    7 文件上传
    6 获取请求头和URL信息
    5 获取Form表单取值
    4 文件操作 支持图片 视频 mp3 文本等
  • 原文地址:https://www.cnblogs.com/fsong/p/4927439.html
Copyright © 2011-2022 走看看