<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ## 數據遷移 遷移就像是數據庫中的版本控制,它讓團隊能夠輕松的修改跟共享應用程序的數據庫結構。新的遷移文件將會被放置在 system/database/migrations 目錄中。每個遷移文件的名稱都包含了一個時間戳,以便讓 hdphp 確認遷移的順序。 [TOC] ## 遷移指令 ### 新增表 ``` php hd make:migration CreateArticleTable --create=article ``` ### 修改表 ``` php hd make:migration ChangeArticleTable --table=article ``` ### 遷移回滾 ``` php hd migrate:rollback ``` ### 遷移重置 執行遷移重置后將會回滾所有遷移數據。 ``` php hd migrate:reset ``` ### 執行遷移 ``` php hd migrate #或執行以下代碼也可 php hd migrate:make ``` ## 操作方法 ### 新增表 新增表是指創建用于構建表的數據遷移文件。 系統將在system/database/migrations 目錄中創建文件,文件包括up與down 兩個方法,up是執行遷移時運行的方法,down是回滾時執行的方法。 ~~~ Schema::create( 'article', function ( Blueprint $table ) { $table->char('hash', 50)->index('hash')->comment('標識'); $table->char( 'name', 30 )->nullable(); },'這是表注釋' ); ~~~ ### 維護表 維護字段指修改已經存在的字段屬性或添加一個新的表字段。 系統將在system/database/migrations 目錄中創建文件,文件包括up與down 兩個方法,up是執行遷移時運行的方法,down是回滾時執行的方法。 文件中添加以下代碼用于修改 name 字段長度為50,并添加新字段 about。 ``` Schema::table('users', function (Blueprint $table) { //修改字段 $table->string('name', 50)->change(); //添加字段 $table->string('about', 100)->add(); }); ``` ## 字段類型 | 命令 |描述 | | --- | --- | | $table->increments | 遞增 ID(主鍵) | | $table->text('description') | 相當于 TEXT 型態 | | $table->mediumtext('content') | 相當于 MEDIUMTEXT 型態 | |$table->tinyInteger('numbers')|相當于 TINYINT 型態| |$table->smallint('numbers')|相當于 SMALLINT 型態| |$table->integer('total')| 相當于 INTEGER(INT) 型態| |$table->mediumint('total')| 相當于 MEDIUMINT 型態| |$table->char('name', 30)|相當于 CHAR 型態,并帶有長度| |$table->string('email') | 相當于 VARCHAR 型態 | |$table->string('name', 100)|相當于 VARCHAR 型態,并帶有長度| |$table->timestamps()|加入 created_at 和 updated_at 字段| |$table->decimal('amount', 5, 2)| DECIMAL 型態,并帶有精度與基數| |$table->double('column', 15, 8)|相當于 DOUBLE 型態,總共有 15 位數,在小數點后面有 8 位數| |$table->enum('sex', ['boy', 'girl'])|相當于 ENUM 型態| |$table->float('amount',5,2)|相當于 FLOAT 型態| |$table->date('createtime')|相當于 DATE 型態| |$table->datetime('createtime')|相當于 DATETIME 型態| ## 字段修飾 除了上述的字段類型列表,還有一些其它的字段「修飾」,你可以將它增加到字段中。例如,若要讓字段「nullable」,那么你可以使用 nullable 方法: ``` Schema::create( 'article', function ( Blueprint $table ) { $table->char( 'name', 30 )->nullable(); },'這是表注釋' ); ``` 以下列表為字段的可用修飾。 | 修飾 | 描述 | | --- | --- | | ->nullable() | 此字段允許寫入 NULL 值 | |->defaults($value)|為此字段指定「默認」值| |->comment('注釋')|增加注釋| |->unsigned()|設置 integer 字段為 UNSIGNED| 使用修飾符的示例如下 ``` Schema::create( 'article', function ( Blueprint $table ) { $table->increments( 'id' ); $table->string( 'title', 100 )->index(); $table->tinyInteger( 'nums' )->unsigned(); $table->char( 'name', 30 )->nullable()->defaults( '后盾網' )->comment( '這是注釋' ); $table->timestamps(); },'這是表注釋'); ``` ## 創建索引 以下指令只有在創建表時可以使用 | 指令 |說明 | | --- | --- | | $table->string('email')->index() | 創建普通索引 | | $table->string('email')->unique()| 創建字段時直接創建該字段的索引 | 維護表時的索引操作請使用 [數據庫組件](http://doc.hdphp.com/215186#_14) 管理索引
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看