初めて投稿させていただきます。よろしくお願いいたします。
プライマリーキーが2つ作られてしまっているような事を書かれている様なのですが、よく分かりませんでした。
勤怠アプリ作成時、マイグレーションでテーブルをCLIで作るときに下記エラーが出でしまいました。
SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key (SQL: create table rests
(id
bigint unsigned not null auto_increment primary key, attendance_id
bigint unsigned not null auto_increment primary key, start_time
time null, end_time
time null, created_at
timestamp default CURRENT_TIMESTAMP null, updated_at
timestamp default CURRENT_TIMESTAMP null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:712
708▕ // If an exception occurs when attempting to run a query, we'll format the error
709▕ // message to include the bindings with SQL, which will make this exception a
710▕ // lot more helpful to the developer instead of just the database's errors.
711▕ catch (Exception $e) {
➜ 712▕ throw new QueryException(
713▕ $query, $this->prepareBindings($bindings), $e
714▕ );
715▕ }
716▕ }
+9 vendor frames
10 database/migrations/2022_06_13_003628_rests.php:24
Illuminate\Support\Facades\Facade::__callStatic("create")
+22 vendor frames
33 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
下記はSQLのデーブルです。作られていませんでした。
mysql> SHOW tables;
+------------------------+
| Tables_in_attendancedb |
+------------------------+
| migrations |
| personal_access_tokens |
+------------------------+
2 rows in set (0.00 sec)
以下URLはGitです。
https://github.com/wakaryo/test2.git
マイグレーションファイルはmigrations下にあります。
教えていただければ幸いです。
拙くて申し訳ないです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/06/15 17:38