zoukankan      html  css  js  c++  java
  • laravel 使用artisan命令新增数据库字段

    cmd 命令行 到项目目录,不是public那个目录

    D:Program FileswampwwwBook>php artisan migrate:make add_machine_typ
    e_to_books
    Created Migration: 2013_09_05_104157_add_machine_type_to_books
    Generating optimized class loader

    migrations目录下面就会生成一个文件,在里面修改即可
    文档可见:http://v3.golaravel.com/docs/database/schema.html

    <?php

    use IlluminateDatabaseMigrationsMigration;

    class AddMachineTypeToBooks extends Migration {

    /**
    * Run the migrations.
    *
    * @return void
    */
    public function up()
    {
    Schema::table('books',function($table){
    $table->integer('machine_type');
    $table->string('lan_ip',100);
    $table->string('remote_ip',100);
    });
    }

    /**
    * Reverse the migrations.
    *
    * @return void
    */
    public function down()
    {
    Schema::table('books',function($table){
    $table->drop_column('machine_type');
    $table->drop_column('lan_ip');
    $table->drop_column('remote_ip');
    });
    }

    }

    分别执行如下,就可以了

    php artisan migrate:refresh

    php artisan db:seed

    由百牛信息技术bainiu.ltd提供

  • 相关阅读:
    sqlhelper类
    嵌入式的n个方向
    study vim + cscope
    mail lists
    关于我的学习
    yahoo enter linux mobile competition
    找工作啦 啦啦啦啦啦
    minicom display unsolicited codes
    并购的年代
    配置rt73无线网卡至suse10.3
  • 原文地址:https://www.cnblogs.com/bainiu/p/7508586.html
Copyright © 2011-2022 走看看