zoukankan      html  css  js  c++  java
  • Laravel 数据库版本管理系统

    database migrationslaravel最强大的功能之一。数据库迁移可以理解为数据库的版本控制器。


    php artisan命令行:

    php artisan make:migration

     ps:该命令行必须在项目的根目录下执行。

    如果对该命令行不是很了解,可是添加参数-h,查看说明文档。

    Usage:
      make:migration [options] [--] <name>
    
    Arguments:
      name                   The name of the migration.
    
    Options:
          --create[=CREATE]  The table to be created.
          --table[=TABLE]    The table to migrate.
          --path[=PATH]      The location where the migration file should be created.
      -h, --help             Display this help message
      -q, --quiet            Do not output any message
      -V, --version          Display this application version
          --ansi             Force ANSI output
          --no-ansi          Disable ANSI output
      -n, --no-interaction   Do not ask any interactive question
          --env[=ENV]        The environment the command should run under.
      -v|vv|vvv, --verbose   Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
    
    Help:
     Create a new migration file

    创建数据表

    1.直接创建。

    php artisan make:migration xxx

    这种方式下生成的数据库表类,只有方法,没有初始化数据表的名字已经字段。

    class Xxx extends Migration
    {
        /**
         * Run the migrations.
         *
         * @return void
         */
        public function up()
        {
            //
        }
    
        /**
         * Reverse the migrations.
         *
         * @return void
         */
        public function down()
        {
            //
        }
    }

    2.添加参数 --create

    php artisan make:migration yyyy --create='yyyy'

     这种方式下生成的数据库表类,不仅初始化了数据表的名字,同时添加了默认字段名。

    class Yyyy extends Migration
    {
        /**
         * Run the migrations.
         *
         * @return void
         */
        public function up()
        {
            Schema::create(''yyyy'', function (Blueprint $table) {
                $table->increments('id');
                $table->timestamps();
            });
        }
    
        /**
         * Reverse the migrations.
         *
         * @return void
         */
        public function down()
        {
            Schema::drop(''yyyy'');
        }
    }

    3.添加参数 --table

    php artisan make:migration yyyyy --table='yyyyy'

     这种方式下生成的数据库表类,已经初始化数据表的名字,但是,没有默认添加字段。

    class Yyyyy extends Migration
    {
        /**
         * Run the migrations.
         *
         * @return void
         */
        public function up()
        {
            Schema::table(''yyyyy'', function (Blueprint $table) {
                //
            });
        }
    
        /**
         * Reverse the migrations.
         *
         * @return void
         */
        public function down()
        {
            Schema::table(''yyyyy'', function (Blueprint $table) {
                //
            });
        }
    }

    不拒打赏:

       

    微信

    支付宝

    本文欢迎转载,转载请注明出处,如果涉及侵权,请企鹅:723887809。
  • 相关阅读:
    手把手教你利用create-nuxt-app脚手架创建NuxtJS应用
    初识NuxtJS
    webpack打包Vue应用程序流程
    用选择器代替表格列的筛选功能
    Element-UI
    Spectral Bounds for Sparse PCA: Exact and Greedy Algorithms[贪婪算法选特征]
    Sparse Principal Component Analysis via Rotation and Truncation
    Generalized Power Method for Sparse Principal Component Analysis
    Sparse Principal Component Analysis via Regularized Low Rank Matrix Approximation(Adjusted Variance)
    Truncated Power Method for Sparse Eigenvalue Problems
  • 原文地址:https://www.cnblogs.com/toxufe/p/5772813.html
Copyright © 2011-2022 走看看