{"id":2625,"date":"2021-09-05T02:40:25","date_gmt":"2021-09-04T17:40:25","guid":{"rendered":"https:\/\/took.jp\/?p=2625"},"modified":"2021-09-05T02:40:25","modified_gmt":"2021-09-04T17:40:25","slug":"laravel-primary-unique-too-long","status":"publish","type":"post","link":"https:\/\/took.jp\/tech-blog\/laravel-primary-unique-too-long\/","title":{"rendered":"Laravel\u306emigration\u30d5\u30a1\u30a4\u30eb\u3067primary, unique\u30ad\u30fc\u304c\u9577\u3059\u304e\u308b\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308b"},"content":{"rendered":"<h2>Laravel\u306emigration\u30d5\u30a1\u30a4\u30eb\u3067primary, unique\u30ad\u30fc\u304c\u9577\u3059\u304e\u308b\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308b<\/h2>\n<p>primary\u30ad\u30fc\u3001 unique\u30ad\u30fc\u304c\u3042\u307e\u308a\u306b\u9577\u3044\u30d5\u30a1\u30a4\u30eb\u540d\u306e\u5834\u5408\u3001migrate\u5b9f\u884c\u6642\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u3068\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"\"><code class=\"language-other\">  1   Doctrine\\DBAL\\Driver\\PDOException::(\"SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name '' is too long\")<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u30ad\u30fc\u540d\u3092\u6307\u5b9a\u3057\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u3001\u81ea\u52d5\u3067\u751f\u6210\u3055\u308c\u305f\u30ad\u30fc\u540d\u304c\u9577\u3059\u304e\u308b\u3053\u3068\u3067\u3001\u30a8\u30e9\u30fc\u3068\u306a\u3063\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u305f\u5834\u5408\u306b\u306f\u3001<\/p>\n<p>\u300cuser_id_primary1_primary2_primary3_primary\u300d\u306e\u3088\u3046\u306a\u30ad\u30fc\u540d\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"line-numbers\"><code class=\"language-php\">$table-&gt;primary(['user_id,  primary1, primary2', 'primary3']);<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h3>\u89e3\u6c7a\u65b9\u6cd5<\/h3>\n<p>\u7b2c2\u5f15\u6570\u306b\u8a2d\u5b9a\u3057\u305f\u3044\u30ad\u30fc\u540d\u3092\u6e21\u3057\u3066\u3042\u3052\u308c\u3070\u826f\u3044\u3067\u3059\u3002<\/p>\n<pre class=\"line-numbers\"><code class=\"language-php\">$table-&gt;primary(['user_id, primary1, primary2', 'primary3'], 'user_table_primary');<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u3061\u306a\u307f\u306b\u3067\u3059\u304c\u3001<\/p>\n<p>unique\u30ad\u30fc\u306e\u5834\u5408\u3001\u8a2d\u5b9a\u3057\u305f\u30ad\u30fc\u540d\u304c\u4f7f\u7528\u3055\u308c\u308b\u306e\u3067\u3059\u304c\u3001<\/p>\n<p>primary\u30ad\u30fc\u306e\u5834\u5408\u306f\u3001\u30c6\u30fc\u30d6\u30eb\u306b\u8907\u6570\u5b58\u5728\u3057\u306a\u3044\u305f\u3081\u306a\u306e\u304b\u3001\u30ad\u30fc\u540d\u306f\u8a2d\u5b9a\u3055\u308c\u306a\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001dummy\u7b49\u306e\u9069\u5f53\u306a\u540d\u524d\u3092\u8a2d\u5b9a\u3057\u3066\u304a\u304f\u7b49\u3067\u3082\u554f\u984c\u306a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u6c17\u306b\u306a\u308b\u304b\u305f\u306f\u3001primary, unique\u3092\u8a2d\u5b9a\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u4f5c\u6210\u5f8c\u3001\u300cshow create table \u30c6\u30fc\u30d6\u30eb\u540d\u300d\u3067\u5b9f\u884c\u3059\u308c\u3070\u3001\u78ba\u8a8d\u3067\u304d\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laravel\u306emigration\u30d5\u30a1\u30a4\u30eb\u3067primary, unique\u30ad\u30fc\u304c\u9577\u3059\u304e\u308b\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308b primary\u30ad\u30fc\u3001 unique\u30ad\u30fc\u304c\u3042\u307e\u308a\u306b\u9577\u3044\u30d5\u30a1\u30a4\u30eb\u540d\u306e\u5834\u5408\u3001migrate\u5b9f\u884c\u6642\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30a8\u30e9\u30fc\u3068\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002 1 \u2026<\/p>\n","protected":false},"author":3,"featured_media":2626,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105,67],"tags":[],"class_list":["post-2625","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-php"],"_links":{"self":[{"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/posts\/2625","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/comments?post=2625"}],"version-history":[{"count":0,"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/posts\/2625\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/media\/2626"}],"wp:attachment":[{"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/media?parent=2625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/categories?post=2625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/took.jp\/tech-blog\/wp-json\/wp\/v2\/tags?post=2625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}