Quantcast
Channel: omnioo lab. record » PHP/MySQL
Viewing all articles
Browse latest Browse all 59

Laravel5でDuplicate column name ‘created_at’

$
0
0

Laravel5のマイグレーション実行時に
$ php artisan migrate
こんな感じのコマンドを実行するんですが、

[PDOException]
SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name ‘created_at’

こんなエラーでテーブルの作成ができないです。
/databaes/migrations/内の該当のphpファイルを開いてSchema::createの中身を確認すると、
$table->timestamps();
があると思います。これ、引数をとったらダメなんですね。メソッド1つで、
create_at timestamp 0000-00-00 00:00:00
update_at timestamp 0000-00-00 00:00:00
が自動的に作成されます。便利ですね。(便利だけど知らないとエラーになりますね。)

StackOverflowでもありました。
https://translate.googleusercontent.com/translate_c?depth=1&hl=ja&prev=search&rurl=translate.google.co.jp&sl=en&u=http://stackoverflow.com/questions/30548214/databse-migration-throws-error-while-seeding-two-timestamp-columns-laravel-5&usg=ALkJrhhUEX95AHywN_tViCl-UcIO6Z5vcg


Viewing all articles
Browse latest Browse all 59

Trending Articles