内容へ移動
ゆーものメモ帳
ユーザ用ツール
管理
ログイン
サイト用ツール
検索
ツール
文書の表示
以前のリビジョン
バックリンク
最近の変更
メディアマネージャー
サイトマップ
ログイン
>
最近の変更
メディアマネージャー
サイトマップ
トレース:
プログラム言語:php:laravel:マイグレーション:tinyintのカラム属性の変更
この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。
====== 【Laravel】マイグレーションで tinyint のカラム属性の変更 ====== マイグレーションで DB のカラム属性の変更に使う change() は、残念ながら tinyInteger に対応していない。\\ なので、以下のようなマイグレーションを実行しようとすると <code:bash> public function up() { Schema::table('users', function (Blueprint $table) { $table->tinyInteger('number')->nullable()->comment('数値')->change(); }); } </code> 以下のようなエラーが表示されてしまう。 > Unknown column type "tinyinteger" 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. 対処法としては、以下のようにカラム属性を変更する sql 文を直接書くとマイグレーションが通る。 <code:bash> public function up() { Schema::table('users', function (Blueprint $table) { DB::statement('alter table users modify column number tinyint not null comment "数値"'); }); } </code>
プログラム言語/php/laravel/マイグレーション/tinyintのカラム属性の変更.txt
· 最終更新: 2021/03/30 17:35 by
humolife
ページ用ツール
文書の表示
以前のリビジョン
バックリンク
文書の先頭へ