亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Laravel 5.8 在“char”類型列遷移時出錯

Laravel 5.8 在“char”類型列遷移時出錯

PHP
倚天杖 2023-03-11 15:03:44
你的觀點是混亂的。首先添加表單操作然后添加按鈕表單屬性,如下所示:<button type="submit" form="upload" class="btn btn-info pull-right" id="submit" data-loading-text='SOME TEXT'> Please wait<?php echo $this->lang->line('save'); ?></button><form id="upload" role="form" method="post" class="ptt10" enctype="multipart/form-data" action="upload_docs">分享703507  703507  703507  我試圖在 laraval 5.8 中使用 php artisan migrate 命令更改我的 char 類型列默認值,但出現以下錯誤:Unknown column type "char" requested. Any Doctrine type that you use has to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database introspection then you might have forgotten to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information.我當前的腳本如下:use Illuminate\Support\Facades\Schema;use Illuminate\Database\Schema\Blueprint;use Illuminate\Database\Migrations\Migration;class AddTypeDeafultValueProjectsTable extends Migration{/** * Run the migrations. * * @return void */public function up(){    Schema::table('projects', function (Blueprint $table) {        $table->char('type', 50)->nullable(true)->change();    });}/** * Reverse the migrations. * * @return void */public function down(){    Schema::table('projects', function (Blueprint $table) {        //    });}}我沒有遇到其他數據類型列的問題,但僅針對 char 出現上述錯誤??梢詭臀医鉀Q這個問題嗎?PHP數據庫拉維laravel-5
查看完整描述

1 回答

?
白衣染霜花

TA貢獻1796條經驗 獲得超10個贊

您需要在遷移腳本中添加以下腳本:

在 use Illuminate\Database\Migrations\Migration 下或之上添加以下內容;

 use Doctrine\DBAL\Types\StringType; use Doctrine\DBAL\Types\Type;

之后在 inside up 函數中添加以下腳本并再次嘗試 php artisan migrate。

    if (!Type::hasType('char')) {
        Type::addType('char', StringType::class);
    }


查看完整回答
反對 回復 2023-03-11
  • 1 回答
  • 0 關注
  • 129 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號