下記の内容でマイグレーションをしたいのですが、出来なくて困っています。ネットでも調べてみたのですが、何が間違っているのかわからない状態です。
public function up() { Schema::create('comics', function (Blueprint $table) { $table->bigIncrements('id'); $table->integer('book_booksGenreId')->unsigned(); $table->string('book_title')->unsigned(); $table->string('book_author')->unsigned(); $table->text('book_largeImageUrl')->unsigned(); $table->timestamps(); }); }
id以外はunsigned()していますが、親テーブルの内容は下記の通りです。
+---------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | title | varchar(255) | NO | | NULL | | | link | varchar(255) | YES | | NULL | | | author | varchar(255) | NO | | NULL | | | category | varchar(255) | YES | | NULL | | | guid | text | YES | | NULL | | | isbn | varchar(255) | YES | | NULL | | | booksGenreId | varchar(255) | YES | | NULL | | | publisherName | varchar(255) | YES | | NULL | | | largeImageUrl | text | YES | | NULL | | | created_at | timestamp | YES | | NULL | | | updated_at | timestamp | YES | | NULL | | +---------------+------------------+------+-----+---------+----------------+ 12 rows in set (0.01 sec)
マイグレーションしようと$php artisan migrateをすると下記のようになります
$ php artisan migrate Migrating: 2022_02_04_164257_create_comics_table Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'unsigned not null, `book_author` varchar(255) unsigned not null, `book_largeI...' at line 1 (SQL: create table `comics` (`id` bigint unsigned not null auto_increment primary key, `book_booksGenreId` int unsigned not null, `book_title` varchar(255) unsigned not null, `book_author` varchar(255) unsigned not null, `book_largeImageUrl` text unsigned not null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci') at /home/ec2-user/environment/book/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669 665| // If an exception occurs when attempting to run a query, we'll format the error 666| // message to include the bindings with SQL, which will make this exception a 667| // lot more helpful to the developer instead of just the database's errors. 668| catch (Exception $e) { > 669| throw new QueryException( 670| $query, $this->prepareBindings($bindings), $e 671| ); 672| } 673| Exception trace: 1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'unsigned not null, `book_author` varchar(255) unsigned not null, `book_largeI...' at line 1") /home/ec2-user/environment/book/vendor/laravel/framework/src/Illuminate/Database/Connection.php:457 2 PDO::prepare() /home/ec2-user/environment/book/vendor/laravel/framework/src/Illuminate/Database/Connection.php:457 Please use the argument -v to see more details.
回答1件
あなたの回答
tips
プレビュー