{"id":2649,"date":"2025-03-24T08:46:52","date_gmt":"2025-03-23T23:46:52","guid":{"rendered":"https:\/\/dexall.co.jp\/articles\/?p=2649"},"modified":"2025-03-24T08:47:20","modified_gmt":"2025-03-23T23:47:20","slug":"%e3%80%90%e4%bf%9d%e5%ad%98%e7%89%88%e3%80%91laravel-migration%e3%81%ae%e5%ae%8c%e5%85%a8%e3%82%ac%e3%82%a4%e3%83%89%ef%bc%9a%e3%83%87%e3%83%bc%e3%82%bf%e3%83%99%e3%83%bc%e3%82%b9%e8%a8%ad%e8%a8%88","status":"publish","type":"post","link":"https:\/\/dexall.co.jp\/articles\/?p=2649","title":{"rendered":"\u3010\u4fdd\u5b58\u7248\u3011Laravel Migration\u306e\u5b8c\u5168\u30ac\u30a4\u30c9\uff1a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u8a2d\u8a08\u304b\u3089\u904b\u7528\u307e\u3067\u89e3\u8aac\uff082025\u5e74\u6700\u65b0\uff09"},"content":{"rendered":"\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>116<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>121<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>128<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\" data-dialog-title=\"\u76ee\u6b21\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">Laravel Migration\u3068\u306f\uff1f\u57fa\u790e\u304b\u3089\u7406\u89e3\u3059\u308b\u4ed5\u7d44\u307f\u3068\u91cd\u8981\u6027<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-1\">\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u306e\u8ab2\u984c\u3068Migration\u306b\u3088\u308b\u89e3\u6c7a<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-2\">Laravel\u304c\u63d0\u4f9b\u3059\u308bMigration\u6a5f\u80fd\u306e\u7279\u5fb4\u3068\u5229\u70b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-3\">Laravel Migration\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u3092\u30de\u30b9\u30bf\u30fc\u3059\u308b<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-4\">\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\u65b9\u6cd5\u3068\u547d\u540d\u898f\u5247<\/a>      <\/li>      <li>        <a href=\"#i-5\">\u30c6\u30fc\u30d6\u30eb\u4f5c\u6210\u30fb\u66f4\u65b0\u30fb\u524a\u9664\u306e\u5177\u4f53\u7684\u306a\u5b9f\u88c5\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-6\">\u30ab\u30e9\u30e0\u5b9a\u7fa9\u3068\u30c7\u30fc\u30bf\u578b\u306e\u4f7f\u3044\u5206\u3051\u65b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-7\">\u5b9f\u8df5\u7684\u306aLaravel Migration\u6d3b\u7528\u30c6\u30af\u30cb\u30c3\u30af<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-8\">\u5916\u90e8\u30ad\u30fc\u3068\u95a2\u9023\u30c6\u30fc\u30d6\u30eb\u306e\u52b9\u7387\u7684\u306a\u7ba1\u7406\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-9\">\u30b7\u30fc\u30c0\u30fc\u3068\u7d44\u307f\u5408\u308f\u305b\u305f\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306e\u4f5c\u6210<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-10\">\u672c\u756a\u74b0\u5883\u3067\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u5b9f\u884c\u6642\u306e\u6ce8\u610f\u70b9<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-11\">Laravel Migration\u306e\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-12\">\u3088\u304f\u3042\u308b\u30a8\u30e9\u30fc\u3068\u305d\u306e\u89e3\u6c7a\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-13\">\u30ed\u30fc\u30eb\u30d0\u30c3\u30af\u6642\u306e\u6ce8\u610f\u70b9\u3068\u5b89\u5168\u306a\u5b9f\u884c\u65b9\u6cd5<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-14\">\u5927\u898f\u6a21\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u306e\u5b9f\u884c\u6642\u306e\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-15\">\u30c1\u30fc\u30e0\u958b\u767a\u306b\u304a\u3051\u308bLaravel Migration\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-16\">\u52b9\u679c\u7684\u306a\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u8a08\u3068\u7ba1\u7406\u65b9\u6cd5<\/a>      <\/li>      <li>        <a href=\"#i-17\">Git\u7ba1\u7406\u3067\u306e\u7af6\u5408\u89e3\u6c7a\u3068\u30de\u30fc\u30b8\u6226\u7565<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-18\">\u74b0\u5883\u5225\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u904b\u7528\u65b9\u91dd<\/a>      <\/li>    <\/ul>  <\/li><\/ul>\n      <a href=\"#\" class=\"sgb-toc-button js-toc-button\" rel=\"nofollow\" data-open-dialog=\"true\"><i class=\"fa fa-list\"><\/i><span class=\"sgb-toc-button__text\">\u76ee\u6b21\u3078<\/span><\/a>\n    <\/div><\/div><h2 class=\"wp-block-heading\" id=\"i-0\">Laravel Migration\u3068\u306f\uff1f\u57fa\u790e\u304b\u3089\u7406\u89e3\u3059\u308b\u4ed5\u7d44\u307f\u3068\u91cd\u8981\u6027<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-1\">\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u306e\u8ab2\u984c\u3068Migration\u306b\u3088\u308b\u89e3\u6c7a<\/h3>\n\n\n\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u7ba1\u7406\u306f\u73fe\u4ee3\u306eWeb\u958b\u767a\u306b\u304a\u3044\u3066\u91cd\u8981\u306a\u8ab2\u984c\u306e\u4e00\u3064\u3067\u3059\u3002\u7279\u306b\u958b\u767a\u30c1\u30fc\u30e0\u304c\u5927\u304d\u304f\u306a\u308b\u306b\u3064\u308c\u3066\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u554f\u984c\u304c\u9855\u5728\u5316\u3057\u3066\u304d\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u69cb\u9020\u306e\u5909\u66f4\u7ba1\u7406<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8907\u6570\u306e\u958b\u767a\u8005\u306b\u3088\u308b\u540c\u6642\u5909\u66f4\u306e\u8ffd\u8de1\u304c\u56f0\u96e3<\/li>\n\n\n\n<li>\u5909\u66f4\u5c65\u6b74\u306e\u7ba1\u7406\u304c\u5c5e\u4eba\u5316\u3057\u3084\u3059\u3044<\/li>\n\n\n\n<li>\u672c\u756a\u74b0\u5883\u3078\u306e\u5909\u66f4\u9069\u7528\u6642\u306e\u30ea\u30b9\u30af\u7ba1\u7406<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u74b0\u5883\u9593\u306e\u6574\u5408\u6027\u78ba\u4fdd<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u958b\u767a\u74b0\u5883\u3068\u672c\u756a\u74b0\u5883\u306e\u69cb\u9020\u306e\u5dee\u7570<\/li>\n\n\n\n<li>\u30c6\u30b9\u30c8\u74b0\u5883\u306e\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7\u30b3\u30b9\u30c8\u304c\u9ad8\u3044<\/li>\n\n\n\n<li>\u74b0\u5883\u3054\u3068\u306e\u624b\u52d5\u5909\u66f4\u306b\u3088\u308b\u30d2\u30e5\u30fc\u30de\u30f3\u30a8\u30e9\u30fc<\/li>\n<\/ul>\n\n\n\n<p>Laravel Migration\u306f\u3001\u3053\u308c\u3089\u306e\u8ab2\u984c\u306b\u5bfe\u3057\u3066\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u89e3\u6c7a\u7b56\u3092\u63d0\u4f9b\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30b3\u30fc\u30c9\u30d9\u30fc\u30b9\u3067\u306e\u5909\u66f4\u7ba1\u7406<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ 2024_02_07_create_users_table.php\npublic function up()\n{\n    Schema::create('users', function (Blueprint $table) {\n        $table-&gt;id();\n        $table-&gt;string('name');\n        $table-&gt;string('email')-&gt;unique();\n        $table-&gt;timestamps();\n    });\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0\u3068\u306e\u7d71\u5408<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5168\u3066\u306e\u5909\u66f4\u304cGit\u306a\u3069\u3067\u8ffd\u8de1\u53ef\u80fd<\/li>\n\n\n\n<li>\u30c1\u30fc\u30e0\u5185\u3067\u306e\u30ec\u30d3\u30e5\u30fc\u304c\u5bb9\u6613<\/li>\n\n\n\n<li>\u30ed\u30fc\u30eb\u30d0\u30c3\u30af\u304c\u5b89\u5168\u306b\u5b9f\u884c\u53ef\u80fd<\/li>\n<\/ul>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u81ea\u52d5\u5316\u3055\u308c\u305f\u9069\u7528\u30d7\u30ed\u30bb\u30b9<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u5168\u3066\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\nphp artisan migrate\n\n# \u5909\u66f4\u3092\u5143\u306b\u623b\u3059\nphp artisan migrate:rollback\n\n# \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u30ea\u30d5\u30ec\u30c3\u30b7\u30e5\nphp artisan migrate:fresh<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-2\">Laravel\u304c\u63d0\u4f9b\u3059\u308bMigration\u6a5f\u80fd\u306e\u7279\u5fb4\u3068\u5229\u70b9<\/h3>\n\n\n\n<p>Laravel\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u6a5f\u80fd\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u7279\u5fb4\u3068\u5229\u70b9\u304c\u3042\u308a\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u76f4\u611f\u7684\u306a\u30b9\u30ad\u30fc\u30de\u5b9a\u7fa9<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Schema::create('products', function (Blueprint $table) {\n    \/\/ \u4e3b\u30ad\u30fc\u306e\u5b9a\u7fa9\n    $table-&gt;id();\n\n    \/\/ \u57fa\u672c\u7684\u306a\u30ab\u30e9\u30e0\n    $table-&gt;string('name');\n    $table-&gt;text('description');\n    $table-&gt;decimal('price', 8, 2);\n\n    \/\/ \u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\n    $table-&gt;timestamps();\n\n    \/\/ \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3068\u5236\u7d04\n    $table-&gt;unique('name');\n    $table-&gt;index('price');\n});<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u5805\u7262\u306a\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u306e\u4ed5\u7d44\u307f<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30c6\u30fc\u30d6\u30eb\u306b\u3088\u308b\u5b9f\u884c\u5c65\u6b74\u306e\u7ba1\u7406<\/li>\n\n\n\n<li>\u30d0\u30c3\u30c1\u756a\u53f7\u306b\u3088\u308b\u5b9f\u884c\u30b0\u30eb\u30fc\u30d7\u306e\u5236\u5fa1<\/li>\n\n\n\n<li>\u30ed\u30fc\u30eb\u30d0\u30c3\u30af\u6a5f\u80fd\u306b\u3088\u308b\u5b89\u5168\u306a\u5909\u66f4\u306e\u53d6\u308a\u6d88\u3057<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function down()\n{\n    Schema::dropIfExists('products');\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u8c4a\u5bcc\u306a\u30c7\u30fc\u30bf\u578b\u3068\u30e2\u30c7\u30a3\u30d5\u30a1\u30a4\u30a2<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u57fa\u672c\u30c7\u30fc\u30bf\u578b<\/strong>\uff1astring, integer, decimal, datetime, json, enum<\/li>\n\n\n\n<li><strong>\u30e2\u30c7\u30a3\u30d5\u30a1\u30a4\u30a2<\/strong>\uff1anullable(), default(), unique(), unsigned()<\/li>\n\n\n\n<li><strong>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3068\u5236\u7d04<\/strong>\uff1aindex(), unique(), foreign()<\/li>\n<\/ul>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u958b\u767a\u52b9\u7387\u3092\u9ad8\u3081\u308b\u6a5f\u80fd\u7fa4<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Artisan\u30b3\u30de\u30f3\u30c9\u306b\u3088\u308b\u81ea\u52d5\u751f\u6210<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   php artisan make:migration create_products_table\n   php artisan make:model Product --migration<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30b7\u30fc\u30c0\u30fc\u3068\u306e\u9023\u643a\u306b\u3088\u308b\u521d\u671f\u30c7\u30fc\u30bf\u7ba1\u7406<\/li>\n\n\n\n<li>\u30c6\u30b9\u30c8\u74b0\u5883\u306e\u5bb9\u6613\u306a\u69cb\u7bc9<\/li>\n<\/ul>\n\n\n\n<p>Laravel Migration\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u958b\u767a\u4e0a\u306e\u5229\u70b9\u304c\u5f97\u3089\u308c\u307e\u3059\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30c1\u30fc\u30e0\u5168\u4f53\u3067\u306e\u4e00\u8cab\u3057\u305f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u7ba1\u7406<\/li>\n\n\n\n<li>\u5909\u66f4\u5c65\u6b74\u306e\u900f\u660e\u6027\u78ba\u4fdd<\/li>\n\n\n\n<li>\u74b0\u5883\u9593\u306e\u78ba\u5b9f\u306a\u540c\u671f<\/li>\n\n\n\n<li>\u30c7\u30d7\u30ed\u30a4\u30e1\u30f3\u30c8\u30ea\u30b9\u30af\u306e\u4f4e\u6e1b<\/li>\n\n\n\n<li>\u30b3\u30fc\u30c9\u30ec\u30d3\u30e5\u30fc\u3092\u901a\u3058\u305f\u54c1\u8cea\u7ba1\u7406<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-3\">Laravel Migration\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u3092\u30de\u30b9\u30bf\u30fc\u3059\u308b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-4\">\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\u65b9\u6cd5\u3068\u547d\u540d\u898f\u5247<\/h3>\n\n\n\n<p>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\u306b\u306f\u3001Laravel\u306eartisan\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u57fa\u672c\u7684\u306a\u4f5c\u6210\u65b9\u6cd5\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u57fa\u672c\u7684\u306a\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\nphp artisan make:migration create_users_table\n\n# \u30c6\u30fc\u30d6\u30eb\u4f5c\u6210\u3092\u542b\u3080\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\nphp artisan make:migration create_users_table --create=users\n\n# \u30c6\u30fc\u30d6\u30eb\u66f4\u65b0\u7528\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\nphp artisan make:migration add_phone_to_users_table --table=users<\/pre>\n\n\n\n<p>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u306e\u547d\u540d\u898f\u5247\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30c6\u30fc\u30d6\u30eb\u4f5c\u6210\u6642<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d1\u30bf\u30fc\u30f3\uff1a<code>create_{\u30c6\u30fc\u30d6\u30eb\u540d}_table<\/code><\/li>\n\n\n\n<li>\u4f8b\uff1a<code>create_users_table<\/code>, <code>create_products_table<\/code><\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30c6\u30fc\u30d6\u30eb\u66f4\u65b0\u6642<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d1\u30bf\u30fc\u30f3\uff1a<code>add_{\u30ab\u30e9\u30e0\u540d}_to_{\u30c6\u30fc\u30d6\u30eb\u540d}_table<\/code><\/li>\n\n\n\n<li>\u4f8b\uff1a<code>add_phone_to_users_table<\/code>, <code>add_status_to_orders_table<\/code><\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u305d\u306e\u4ed6\u306e\u5909\u66f4\u6642<\/strong><\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d1\u30bf\u30fc\u30f3\uff1a<code>{\u52d5\u4f5c}_{\u5bfe\u8c61}_{\u30c6\u30fc\u30d6\u30eb\u540d}_table<\/code><\/li>\n\n\n\n<li>\u4f8b\uff1a<code>modify_status_in_orders_table<\/code>, <code>drop_unused_columns_from_users_table<\/code><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-5\">\u30c6\u30fc\u30d6\u30eb\u4f5c\u6210\u30fb\u66f4\u65b0\u30fb\u524a\u9664\u306e\u5177\u4f53\u7684\u306a\u5b9f\u88c5\u65b9\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30c6\u30fc\u30d6\u30eb\u306e\u4f5c\u6210<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function up()\n{\n    Schema::create('orders', function (Blueprint $table) {\n        \/\/ \u4e3b\u30ad\u30fc\u3068\u57fa\u672c\u60c5\u5831\n        $table-&gt;id();\n        $table-&gt;string('order_number')-&gt;unique();\n        $table-&gt;foreignId('user_id')-&gt;constrained();\n\n        \/\/ \u6ce8\u6587\u60c5\u5831\n        $table-&gt;decimal('total_amount', 10, 2);\n        $table-&gt;enum('status', ['pending', 'processing', 'completed', 'cancelled']);\n\n        \/\/ \u30e1\u30bf\u60c5\u5831\n        $table-&gt;text('notes')-&gt;nullable();\n        $table-&gt;timestamps();\n        $table-&gt;softDeletes();\n    });\n}\n\npublic function down()\n{\n    Schema::dropIfExists('orders');\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30c6\u30fc\u30d6\u30eb\u306e\u66f4\u65b0<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function up()\n{\n    Schema::table('orders', function (Blueprint $table) {\n        \/\/ \u30ab\u30e9\u30e0\u306e\u8ffd\u52a0\n        $table-&gt;string('shipping_address')-&gt;after('status');\n\n        \/\/ \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u8ffd\u52a0\n        $table-&gt;index(['status', 'created_at']);\n\n        \/\/ \u5916\u90e8\u30ad\u30fc\u306e\u8ffd\u52a0\n        $table-&gt;foreignId('shipping_method_id')\n              -&gt;after('shipping_address')\n              -&gt;constrained()\n              -&gt;onDelete('restrict');\n    });\n}\n\npublic function down()\n{\n    Schema::table('orders', function (Blueprint $table) {\n        \/\/ \u8ffd\u52a0\u3057\u305f\u8981\u7d20\u3092\u9006\u9806\u3067\u524a\u9664\n        $table-&gt;dropForeign(['shipping_method_id']);\n        $table-&gt;dropColumn(['shipping_address', 'shipping_method_id']);\n        $table-&gt;dropIndex(['status', 'created_at']);\n    });\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30ab\u30e9\u30e0\u306e\u5909\u66f4<\/strong>\uff08doctribe\/dbal\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u5fc5\u8981\uff09<\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function up()\n{\n    Schema::table('orders', function (Blueprint $table) {\n        \/\/ \u30ab\u30e9\u30e0\u306e\u5c5e\u6027\u5909\u66f4\n        $table-&gt;string('order_number', 20)-&gt;change();\n        $table-&gt;text('notes')-&gt;nullable(false)-&gt;change();\n\n        \/\/ \u30ab\u30e9\u30e0\u540d\u306e\u5909\u66f4\n        $table-&gt;renameColumn('shipping_address', 'delivery_address');\n    });\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-6\">\u30ab\u30e9\u30e0\u5b9a\u7fa9\u3068\u30c7\u30fc\u30bf\u578b\u306e\u4f7f\u3044\u5206\u3051\u65b9<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u4e3b\u8981\u306a\u30c7\u30fc\u30bf\u578b\u3068\u305d\u306e\u7528\u9014<\/strong><\/li>\n<\/ol>\n\n\n<div id=\"id-0fd2b7a5-db74-42b9-ae47-1b7c02dec858\">\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u30c7\u30fc\u30bf\u578b<\/th><th>\u8aac\u660e<\/th><th>\u9069\u3057\u305f\u7528\u9014<\/th><\/tr><\/thead><tbody><tr><td><code>string<\/code><\/td><td>\u53ef\u5909\u9577\u6587\u5b57\u5217\uff08\u6700\u5927255\u6587\u5b57\uff09<\/td><td>\u30e6\u30fc\u30b6\u30fc\u540d\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3001\u30d1\u30b9\u30ef\u30fc\u30c9<\/td><\/tr><tr><td><code>text<\/code><\/td><td>\u9577\u6587\u30c6\u30ad\u30b9\u30c8<\/td><td>\u5546\u54c1\u8aac\u660e\u3001\u8a18\u4e8b\u672c\u6587\u3001\u30b3\u30e1\u30f3\u30c8<\/td><\/tr><tr><td><code>integer<\/code><\/td><td>\u6574\u6570\u5024<\/td><td>ID\u3001\u5e74\u9f62\u3001\u6570\u91cf<\/td><\/tr><tr><td><code>decimal<\/code><\/td><td>\u7cbe\u5ea6\u304c\u5fc5\u8981\u306a\u5c0f\u6570<\/td><td>\u91d1\u984d\u3001\u91cd\u91cf\u3001\u5ea7\u6a19<\/td><\/tr><tr><td><code>boolean<\/code><\/td><td>\u771f\u507d\u5024<\/td><td>\u30d5\u30e9\u30b0\u3001\u72b6\u614b\u3001\u8a2d\u5b9a\u5024<\/td><\/tr><tr><td><code>date<\/code><\/td><td>\u65e5\u4ed8<\/td><td>\u751f\u5e74\u6708\u65e5\u3001\u4e88\u5b9a\u65e5<\/td><\/tr><tr><td><code>datetime<\/code><\/td><td>\u65e5\u6642<\/td><td>\u6295\u7a3f\u65e5\u6642\u3001\u4e88\u7d04\u6642\u9593<\/td><\/tr><tr><td><code>json<\/code><\/td><td>JSON\u5f62\u5f0f\u30c7\u30fc\u30bf<\/td><td>\u8a2d\u5b9a\u5024\u3001\u5c5e\u6027\u60c5\u5831<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u3088\u304f\u4f7f\u7528\u3059\u308b\u30e2\u30c7\u30a3\u30d5\u30a1\u30a4\u30a2<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$table-&gt;string('name', 100);           \/\/ \u6700\u5927\u9577\u3092\u6307\u5b9a\n$table-&gt;decimal('price', 8, 2);        \/\/ \u5168\u4f53\u6841\u6570\u3068\u5c0f\u6570\u6841\u6570\u3092\u6307\u5b9a\n$table-&gt;integer('count')-&gt;unsigned();   \/\/ \u7b26\u53f7\u306a\u3057\u6574\u6570\n$table-&gt;string('email')-&gt;unique();      \/\/ \u30e6\u30cb\u30fc\u30af\u5236\u7d04\n$table-&gt;text('memo')-&gt;nullable();       \/\/ NULL\u8a31\u5bb9\n$table-&gt;boolean('active')-&gt;default(true); \/\/ \u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u8a2d\u5b9a<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3068\u5236\u7d04\u306e\u9069\u5207\u306a\u8a2d\u5b9a<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Schema::create('products', function (Blueprint $table) {\n    $table-&gt;id();\n    $table-&gt;string('sku')-&gt;unique();    \/\/ \u5546\u54c1\u30b3\u30fc\u30c9\uff08\u4e00\u610f\uff09\n    $table-&gt;string('name');\n    $table-&gt;decimal('price', 8, 2);\n\n    \/\/ \u8907\u5408\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\n    $table-&gt;index(['name', 'price']);\n\n    \/\/ \u5916\u90e8\u30ad\u30fc\u5236\u7d04\n    $table-&gt;foreignId('category_id')\n          -&gt;constrained()\n          -&gt;onDelete('cascade');\n\n    \/\/ \u8907\u5408\u30e6\u30cb\u30fc\u30af\u5236\u7d04\n    $table-&gt;unique(['sku', 'name']);\n\n    $table-&gt;timestamps();\n});<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30b9\u30ad\u30fc\u30de\u3092\u52b9\u7387\u7684\u306b\u7ba1\u7406\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u6b21\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001\u3088\u308a\u5b9f\u8df5\u7684\u306a\u6d3b\u7528\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-7\">\u5b9f\u8df5\u7684\u306aLaravel Migration\u6d3b\u7528\u30c6\u30af\u30cb\u30c3\u30af<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-8\">\u5916\u90e8\u30ad\u30fc\u3068\u95a2\u9023\u30c6\u30fc\u30d6\u30eb\u306e\u52b9\u7387\u7684\u306a\u7ba1\u7406\u65b9\u6cd5<\/h3>\n\n\n\n<p>\u8907\u96d1\u306a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u8a2d\u8a08\u3067\u306f\u3001\u30c6\u30fc\u30d6\u30eb\u9593\u306e\u95a2\u9023\u3092\u9069\u5207\u306b\u7ba1\u7406\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002\u4ee5\u4e0b\u306b\u3001\u4e3b\u8981\u306a\u30d1\u30bf\u30fc\u30f3\u3068\u5b9f\u88c5\u65b9\u6cd5\u3092\u793a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u4e00\u5bfe\u591a\u306e\u95a2\u4fc2<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u57fa\u672c\u7684\u306a\u4e00\u5bfe\u591a\u306e\u95a2\u4fc2\uff08\u30e6\u30fc\u30b6\u30fc\u3068\u6ce8\u6587\uff09\nSchema::create('orders', function (Blueprint $table) {\n    $table-&gt;id();\n    $table-&gt;foreignId('user_id')\n          -&gt;constrained()\n          -&gt;onDelete('cascade');\n    $table-&gt;string('order_number');\n    $table-&gt;timestamps();\n});<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u591a\u5bfe\u591a\u306e\u95a2\u4fc2<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u5546\u54c1\u3068\u30bf\u30b0\u306e\u591a\u5bfe\u591a\u306e\u95a2\u4fc2\nSchema::create('products', function (Blueprint $table) {\n    $table-&gt;id();\n    $table-&gt;string('name');\n    $table-&gt;timestamps();\n});\n\nSchema::create('tags', function (Blueprint $table) {\n    $table-&gt;id();\n    $table-&gt;string('name');\n    $table-&gt;timestamps();\n});\n\n\/\/ \u4e2d\u9593\u30c6\u30fc\u30d6\u30eb\nSchema::create('product_tag', function (Blueprint $table) {\n    $table-&gt;id();\n    $table-&gt;foreignId('product_id')-&gt;constrained()-&gt;onDelete('cascade');\n    $table-&gt;foreignId('tag_id')-&gt;constrained()-&gt;onDelete('cascade');\n    $table-&gt;timestamps();\n\n    \/\/ \u91cd\u8907\u3092\u9632\u3050\u305f\u3081\u306e\u30e6\u30cb\u30fc\u30af\u5236\u7d04\n    $table-&gt;unique(['product_id', 'tag_id']);\n});<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u95a2\u9023<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u753b\u50cf\u30c6\u30fc\u30d6\u30eb\uff08\u8907\u6570\u306e\u30e2\u30c7\u30eb\u306b\u95a2\u9023\u4ed8\u3051\u53ef\u80fd\uff09\nSchema::create('images', function (Blueprint $table) {\n    $table-&gt;id();\n    $table-&gt;morphs('imageable');  \/\/ imageable_id, imageable_type\u30ab\u30e9\u30e0\u3092\u4f5c\u6210\n    $table-&gt;string('path');\n    $table-&gt;timestamps();\n});<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-9\">\u30b7\u30fc\u30c0\u30fc\u3068\u7d44\u307f\u5408\u308f\u305b\u305f\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306e\u4f5c\u6210<\/h3>\n\n\n\n<p>\u52b9\u7387\u7684\u306a\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u7ba1\u7406\u306e\u305f\u3081\u306b\u306f\u3001\u30b7\u30fc\u30c0\u30fc\u3068\u30d5\u30a1\u30af\u30c8\u30ea\u30fc\u3092\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u57fa\u672c\u7684\u306a\u30b7\u30fc\u30c0\u30fc\u306e\u5b9f\u88c5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ database\/seeders\/ProductSeeder.php\npublic function run()\n{\n    \/\/ \u57fa\u672c\u30c7\u30fc\u30bf\u306e\u4f5c\u6210\n    Product::create([\n        'name' =&gt; '\u57fa\u672c\u5546\u54c1',\n        'price' =&gt; 1000,\n        'description' =&gt; '\u57fa\u672c\u7684\u306a\u5546\u54c1\u8aac\u660e'\n    ]);\n\n    \/\/ \u30d5\u30a1\u30af\u30c8\u30ea\u30fc\u3092\u4f7f\u7528\u3057\u305f\u5927\u91cf\u30c7\u30fc\u30bf\u751f\u6210\n    Product::factory()\n        -&gt;count(50)\n        -&gt;create();\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u95a2\u9023\u3092\u6301\u3064\u30c7\u30fc\u30bf\u306e\u751f\u6210<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ database\/seeders\/OrderSeeder.php\npublic function run()\n{\n    \/\/ \u30e6\u30fc\u30b6\u30fc\u3068\u6ce8\u6587\u3092\u540c\u6642\u306b\u751f\u6210\n    User::factory()\n        -&gt;count(10)\n        -&gt;has(\n            Order::factory()\n                -&gt;count(3)\n                -&gt;state(function (array $attributes, User $user) {\n                    return ['total_amount' =&gt; rand(1000, 10000)];\n                })\n        )\n        -&gt;create();\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u74b0\u5883\u5225\u306e\u30b7\u30fc\u30c7\u30a3\u30f3\u30b0\u5236\u5fa1<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ database\/seeders\/DatabaseSeeder.php\npublic function run()\n{\n    if (app()-&gt;environment('local', 'development')) {\n        \/\/ \u958b\u767a\u74b0\u5883\u7528\u306e\u5927\u91cf\u30c7\u30fc\u30bf\n        $this-&gt;call([\n            UserSeeder::class,\n            ProductSeeder::class,\n            OrderSeeder::class,\n        ]);\n    } else {\n        \/\/ \u672c\u756a\u74b0\u5883\u7528\u306e\u6700\u5c0f\u30c7\u30fc\u30bf\n        $this-&gt;call([\n            BasicDataSeeder::class,\n        ]);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-10\">\u672c\u756a\u74b0\u5883\u3067\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u5b9f\u884c\u6642\u306e\u6ce8\u610f\u70b9<\/h3>\n\n\n\n<p>\u672c\u756a\u74b0\u5883\u3067\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u5b9f\u884c\u306b\u306f\u7d30\u5fc3\u306e\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002\u4ee5\u4e0b\u306b\u4e3b\u8981\u306a\u6ce8\u610f\u70b9\u3068\u5bfe\u7b56\u3092\u793a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5b89\u5168\u306a\u30c7\u30fc\u30bf\u66f4\u65b0<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function up()\n{\n    \/\/ \u65b0\u3057\u3044\u30ab\u30e9\u30e0\u306e\u8ffd\u52a0\uff08NULL\u8a31\u5bb9\u3067\u8ffd\u52a0\uff09\n    Schema::table('users', function (Blueprint $table) {\n        $table-&gt;string('phone_number')-&gt;nullable()-&gt;after('email');\n    });\n\n    \/\/ \u65e2\u5b58\u30c7\u30fc\u30bf\u306e\u66f4\u65b0\uff08\u30d0\u30c3\u30c1\u51e6\u7406\uff09\n    User::chunk(1000, function ($users) {\n        foreach ($users as $user) {\n            $user-&gt;phone_number = '\u672a\u8a2d\u5b9a';\n            $user-&gt;save();\n        }\n    });\n\n    \/\/ NULL\u3092\u8a31\u5bb9\u3057\u306a\u3044\u8a2d\u5b9a\u306b\u5909\u66f4\n    Schema::table('users', function (Blueprint $table) {\n        $table-&gt;string('phone_number')-&gt;nullable(false)-&gt;change();\n    });\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u8003\u616e\u3057\u305f\u5b9f\u88c5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function up()\n{\n    \/\/ \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u8ffd\u52a0\uff08\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u51e6\u7406\uff09\n    Schema::table('large_table', function (Blueprint $table) {\n        $table-&gt;index('column_name')-&gt;algorithm('concurrently');\n    });\n\n    \/\/ \u5927\u91cf\u30c7\u30fc\u30bf\u306e\u66f4\u65b0\n    DB::statement('UPDATE users SET status = \"active\" WHERE created_at &lt; ?', [\n        now()-&gt;subMonths(3)\n    ]);\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u5b9f\u884c\u524d\u306e\u78ba\u8a8d\u3068\u6e96\u5099<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u5b9f\u884c\u524d\u306e\u78ba\u8a8d\nphp artisan migrate --pretend\n\n# \u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u30e2\u30fc\u30c9\u306e\u6709\u52b9\u5316\nphp artisan down --message=\"\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u4e2d\u3067\u3059\" --retry=60\n\n# \u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u306e\u4f5c\u6210\nphp artisan backup:run --only-db\n\n# \u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u5b9f\u884c\nphp artisan migrate --force\n\n# \u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u30e2\u30fc\u30c9\u306e\u89e3\u9664\nphp artisan up<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3092\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u5b89\u5168\u3067\u52b9\u7387\u7684\u306a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u7ba1\u7406\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-11\">Laravel Migration\u306e\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-12\">\u3088\u304f\u3042\u308b\u30a8\u30e9\u30fc\u3068\u305d\u306e\u89e3\u6c7a\u65b9\u6cd5<\/h3>\n\n\n\n<p>Laravel Migration\u3092\u4f7f\u7528\u3059\u308b\u969b\u306b\u3088\u304f\u906d\u9047\u3059\u308b\u30a8\u30e9\u30fc\u3068\u305d\u306e\u89e3\u6c7a\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30c6\u30fc\u30d6\u30eb\u304c\u65e2\u306b\u5b58\u5728\u3059\u308b\u5834\u5408<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30a8\u30e9\u30fc: Table 'users' already exists\nSchema::create('users', function (Blueprint $table) {\n    \/\/ ...\n});\n\n\/\/ \u89e3\u6c7a\u65b9\u6cd51: createIfNotExists \u3092\u4f7f\u7528\nSchema::createIfNotExists('users', function (Blueprint $table) {\n    \/\/ ...\n});\n\n\/\/ \u89e3\u6c7a\u65b9\u6cd52: dropIfExists \u3092\u5148\u306b\u5b9f\u884c\nSchema::dropIfExists('users');\nSchema::create('users', function (Blueprint $table) {\n    \/\/ ...\n});<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u5916\u90e8\u30ad\u30fc\u5236\u7d04\u306e\u30a8\u30e9\u30fc<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30a8\u30e9\u30fc: Foreign key constraint is incorrectly formed\n$table-&gt;foreignId('user_id')-&gt;constrained();\n\n\/\/ \u89e3\u6c7a\u65b9\u6cd51: \u30c6\u30fc\u30d6\u30eb\u540d\u3092\u660e\u793a\u7684\u306b\u6307\u5b9a\n$table-&gt;foreignId('user_id')-&gt;constrained('users');\n\n\/\/ \u89e3\u6c7a\u65b9\u6cd52: \u30ab\u30b9\u30b1\u30fc\u30c9\u524a\u9664\u3092\u8a2d\u5b9a\n$table-&gt;foreignId('user_id')\n      -&gt;constrained()\n      -&gt;onDelete('cascade');<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30ab\u30e9\u30e0\u5909\u66f4\u6642\u306e\u30a8\u30e9\u30fc<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u30a8\u30e9\u30fc: Changing columns requires doctrine\/dbal package\n$table-&gt;string('name')-&gt;change();\n\n\/\/ \u89e3\u6c7a\u65b9\u6cd5: doctrine\/dbal\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\n\/\/ composer require doctrine\/dbal\n\n\/\/ \u305d\u306e\u5f8c\u3001\u30ab\u30e9\u30e0\u5909\u66f4\u304c\u53ef\u80fd\u306b\nSchema::table('users', function (Blueprint $table) {\n    $table-&gt;string('name', 100)-&gt;change();\n});<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-13\">\u30ed\u30fc\u30eb\u30d0\u30c3\u30af\u6642\u306e\u6ce8\u610f\u70b9\u3068\u5b89\u5168\u306a\u5b9f\u884c\u65b9\u6cd5<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u9069\u5207\u306adown()\u30e1\u30bd\u30c3\u30c9\u306e\u5b9f\u88c5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function up()\n{\n    Schema::table('users', function (Blueprint $table) {\n        $table-&gt;string('phone')-&gt;after('email');\n        $table-&gt;index('phone');\n    });\n}\n\npublic function down()\n{\n    Schema::table('users', function (Blueprint $table) {\n        \/\/ \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u524a\u9664\u3092\u5148\u306b\u884c\u3046\n        $table-&gt;dropIndex(['phone']);\n        \/\/ \u305d\u306e\u5f8c\u3067\u30ab\u30e9\u30e0\u3092\u524a\u9664\n        $table-&gt;dropColumn('phone');\n    });\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30c7\u30fc\u30bf\u640d\u5931\u3092\u9632\u3050\u305f\u3081\u306e\u5bfe\u7b56<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function up()\n{\n    \/\/ \u4e00\u6642\u30c6\u30fc\u30d6\u30eb\u306e\u4f5c\u6210\n    Schema::create('users_backup', function (Blueprint $table) {\n        \/\/ \u65e2\u5b58\u306e\u30c6\u30fc\u30d6\u30eb\u69cb\u9020\u3092\u30b3\u30d4\u30fc\n    });\n\n    \/\/ \u30c7\u30fc\u30bf\u306e\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\n    DB::statement('INSERT INTO users_backup SELECT * FROM users');\n\n    \/\/ \u65e2\u5b58\u30c6\u30fc\u30d6\u30eb\u306e\u5909\u66f4\n    Schema::table('users', function (Blueprint $table) {\n        \/\/ ...\n    });\n}\n\npublic function down()\n{\n    \/\/ \u554f\u984c\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u306e\u30ea\u30b9\u30c8\u30a2\n    if (Schema::hasTable('users_backup')) {\n        Schema::drop('users');\n        DB::statement('ALTER TABLE users_backup RENAME TO users');\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-14\">\u5927\u898f\u6a21\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u306e\u5b9f\u884c\u6642\u306e\u6700\u9069\u5316\u30c6\u30af\u30cb\u30c3\u30af<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30d0\u30c3\u30c1\u51e6\u7406\u306b\u3088\u308b\u5927\u91cf\u30c7\u30fc\u30bf\u306e\u66f4\u65b0<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function up()\n{\n    \/\/ \u30ab\u30e9\u30e0\u306e\u8ffd\u52a0\n    Schema::table('large_table', function (Blueprint $table) {\n        $table-&gt;string('status')-&gt;nullable();\n    });\n\n    \/\/ \u30c7\u30fc\u30bf\u306e\u6bb5\u968e\u7684\u306a\u66f4\u65b0\n    DB::table('large_table')\n        -&gt;orderBy('id')\n        -&gt;chunk(1000, function ($records) {\n            foreach ($records as $record) {\n                DB::table('large_table')\n                    -&gt;where('id', $record-&gt;id)\n                    -&gt;update(['status' =&gt; 'active']);\n            }\n        });\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u64cd\u4f5c\u306e\u6700\u9069\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function up()\n{\n    \/\/ \u4e00\u6642\u7684\u306b\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u524a\u9664\n    Schema::table('large_table', function (Blueprint $table) {\n        $table-&gt;dropIndex(['column_name']);\n    });\n\n    \/\/ \u5927\u91cf\u30c7\u30fc\u30bf\u306e\u66f4\u65b0\u51e6\u7406\n    DB::statement('UPDATE large_table SET status = \"active\"');\n\n    \/\/ \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u518d\u4f5c\u6210\n    Schema::table('large_table', function (Blueprint $table) {\n        $table-&gt;index('column_name');\n    });\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306e\u6700\u9069\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public function up()\n{\n    \/\/ \u30e1\u30e2\u30ea\u5236\u9650\u306e\u4e00\u6642\u7684\u306a\u7de9\u548c\n    ini_set('memory_limit', '512M');\n\n    \/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u8a2d\u5b9a\n    DB::statement('SET SESSION wait_timeout = 300');\n\n    \/\/ \u5927\u898f\u6a21\u306a\u66f4\u65b0\u51e6\u7406\n    DB::table('large_table')\n        -&gt;whereNull('processed_at')\n        -&gt;lazyById(1000)\n        -&gt;each(function ($record) {\n            \/\/ \u51e6\u7406\n        });\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0\u6280\u8853\u3092\u7406\u89e3\u3057\u3001\u9069\u5207\u306b\u5bfe\u5fdc\u3059\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u5b89\u5b9a\u3057\u305f\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u7ba1\u7406\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-15\">\u30c1\u30fc\u30e0\u958b\u767a\u306b\u304a\u3051\u308bLaravel Migration\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-16\">\u52b9\u679c\u7684\u306a\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u8a08\u3068\u7ba1\u7406\u65b9\u6cd5<\/h3>\n\n\n\n<p>\u30c1\u30fc\u30e0\u958b\u767a\u306b\u304a\u3044\u3066\u3001\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u8a08\u3068\u7ba1\u7406\u306f\u91cd\u8981\u306a\u8ab2\u984c\u3067\u3059\u3002\u4ee5\u4e0b\u306b\u52b9\u679c\u7684\u306a\u7ba1\u7406\u65b9\u6cd5\u3092\u793a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u547d\u540d\u898f\u5247\u306e\u6a19\u6e96\u5316<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u63a8\u5968\u3055\u308c\u308b\u547d\u540d\u30d1\u30bf\u30fc\u30f3\nYYYY_MM_DD_HHMMSS_action_target_table.php\n\n\/\/ \u5177\u4f53\u4f8b\n2024_02_07_123456_create_users_table.php\n2024_02_07_123457_add_phone_to_users_table.php\n2024_02_07_123458_modify_status_in_orders_table.php<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u306e\u5206\u5272\u6307\u91dd<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u826f\u3044\u4f8b\uff1a\u6a5f\u80fd\u5358\u4f4d\u3067\u306e\u5206\u5272\nclass CreateOrderSystem extends Migration\n{\n    public function up()\n    {\n        \/\/ \u6ce8\u6587\u30c6\u30fc\u30d6\u30eb\n        Schema::create('orders', function (Blueprint $table) {\n            $table-&gt;id();\n            $table-&gt;foreignId('user_id')-&gt;constrained();\n            $table-&gt;string('order_number');\n            $table-&gt;timestamps();\n        });\n\n        \/\/ \u6ce8\u6587\u8a73\u7d30\u30c6\u30fc\u30d6\u30eb\n        Schema::create('order_items', function (Blueprint $table) {\n            $table-&gt;id();\n            $table-&gt;foreignId('order_id')-&gt;constrained()-&gt;onDelete('cascade');\n            $table-&gt;foreignId('product_id')-&gt;constrained();\n            $table-&gt;integer('quantity');\n            $table-&gt;decimal('price', 10, 2);\n            $table-&gt;timestamps();\n        });\n    }\n\n    public function down()\n    {\n        Schema::dropIfExists('order_items');\n        Schema::dropIfExists('orders');\n    }\n}<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u30b3\u30e1\u30f3\u30c8\u3068\u30c9\u30ad\u30e5\u30e1\u30f3\u30c6\u30fc\u30b7\u30e7\u30f3<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class AddPaymentFieldsToOrders extends Migration\n{\n    \/**\n     * \u6ce8\u6587\u30c6\u30fc\u30d6\u30eb\u306b\u6c7a\u6e08\u95a2\u9023\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8ffd\u52a0\n     * \n     * \u8ffd\u52a0\u3059\u308b\u30d5\u30a3\u30fc\u30eb\u30c9\uff1a\n     * - payment_method: \u6c7a\u6e08\u65b9\u6cd5\uff08enum\uff09\n     * - payment_status: \u6c7a\u6e08\u72b6\u614b\uff08enum\uff09\n     * - paid_at: \u652f\u6255\u5b8c\u4e86\u65e5\u6642\n     * \n     * @return void\n     *\/\n    public function up()\n    {\n        Schema::table('orders', function (Blueprint $table) {\n            \/\/ \u6c7a\u6e08\u65b9\u6cd5\uff08\u30af\u30ec\u30b8\u30c3\u30c8\u30ab\u30fc\u30c9\u3001\u9280\u884c\u632f\u8fbc\u3001\u30b3\u30f3\u30d3\u30cb\u6c7a\u6e08\uff09\n            $table-&gt;enum('payment_method', [\n                'credit_card', \n                'bank_transfer', \n                'convenience_store'\n            ])-&gt;after('order_number');\n\n            \/\/ \u6c7a\u6e08\u72b6\u614b\uff08\u672a\u6c7a\u6e08\u3001\u6c7a\u6e08\u4e2d\u3001\u6c7a\u6e08\u5b8c\u4e86\u3001\u6c7a\u6e08\u5931\u6557\uff09\n            $table-&gt;enum('payment_status', [\n                'unpaid',\n                'processing',\n                'completed',\n                'failed'\n            ])-&gt;default('unpaid');\n\n            \/\/ \u652f\u6255\u5b8c\u4e86\u65e5\u6642\n            $table-&gt;timestamp('paid_at')-&gt;nullable();\n        });\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-17\">Git\u7ba1\u7406\u3067\u306e\u7af6\u5408\u89e3\u6c7a\u3068\u30de\u30fc\u30b8\u6226\u7565<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30d6\u30e9\u30f3\u30c1\u6226\u7565\u3068\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u7ba1\u7406<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u6a5f\u80fd\u958b\u767a\u7528\u30d6\u30e9\u30f3\u30c1\u306e\u4f5c\u6210\ngit checkout -b feature\/add-payment-system\n\n# \u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210\nphp artisan make:migration add_payment_fields_to_orders\n\n# \u5909\u66f4\u3092\u30b3\u30df\u30c3\u30c8\ngit add database\/migrations\/2024_02_07_*.php\ngit commit -m \"feat: \u6ce8\u6587\u30c6\u30fc\u30d6\u30eb\u306b\u6c7a\u6e08\u95a2\u9023\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8ffd\u52a0\"<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u7af6\u5408\u306e\u89e3\u6c7a\u65b9\u6cd5<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u7af6\u5408\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u306e\u5bfe\u51e6\n\/\/ 1. \u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u306e\u8abf\u6574\n\/\/ \u5909\u66f4\u524d\uff1a2024_02_07_123456_add_payment_fields_to_orders.php\n\/\/ \u5909\u66f4\u5f8c\uff1a2024_02_07_123457_add_payment_fields_to_orders.php\n\n\/\/ 2. \u4f9d\u5b58\u95a2\u4fc2\u306e\u660e\u793a\nclass AddPaymentFieldsToOrders extends Migration\n{\n    \/**\n     * \u3053\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u524d\u63d0\u6761\u4ef6\uff1a\n     * - orders \u30c6\u30fc\u30d6\u30eb\u304c\u5b58\u5728\u3059\u308b\u3053\u3068\n     * - order_number \u30ab\u30e9\u30e0\u304c\u5b58\u5728\u3059\u308b\u3053\u3068\n     *\/\n    public function up()\n    {\n        if (!Schema::hasTable('orders') || \n            !Schema::hasColumn('orders', 'order_number')) {\n            throw new \\Exception('\u524d\u63d0\u6761\u4ef6\u304c\u6e80\u305f\u3055\u308c\u3066\u3044\u307e\u305b\u3093');\n        }\n\n        \/\/ \u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u51e6\u7406\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-18\">\u74b0\u5883\u5225\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u904b\u7528\u65b9\u91dd<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u74b0\u5883\u5225\u306e\u8a2d\u5b9a\u7ba1\u7406<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ config\/database.php\n'migrations' =&gt; [\n    'path' =&gt; database_path('migrations'),\n    'schema' =&gt; [\n        'default' =&gt; env('DB_SCHEMA', 'public'),\n        'production' =&gt; env('DB_SCHEMA_PRODUCTION', 'public'),\n    ],\n    'backup' =&gt; env('DB_BACKUP_BEFORE_MIGRATE', true),\n],\n\n\/\/ \u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u5185\u3067\u306e\u74b0\u5883\u5206\u5c90\npublic function up()\n{\n    if (app()-&gt;environment('production')) {\n        \/\/ \u672c\u756a\u74b0\u5883\u7528\u306e\u51e6\u7406\n        Schema::table('users', function (Blueprint $table) {\n            $table-&gt;string('email')-&gt;unique();\n        });\n    } else {\n        \/\/ \u958b\u767a\u74b0\u5883\u7528\u306e\u51e6\u7406\n        Schema::table('users', function (Blueprint $table) {\n            $table-&gt;string('email');\n            $table-&gt;index('email');\n        });\n    }\n}<\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>\u74b0\u5883\u5225\u306e\u30c7\u30d7\u30ed\u30a4\u30e1\u30f3\u30c8\u30d5\u30ed\u30fc<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u958b\u767a\u74b0\u5883\nphp artisan migrate\nphp artisan db:seed --class=DevelopmentSeeder\n\n# \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0\u74b0\u5883\nphp artisan migrate --force\nphp artisan db:seed --class=StagingSeeder\n\n# \u672c\u756a\u74b0\u5883\nphp artisan down\nphp artisan backup:run\nphp artisan migrate --force --no-interaction\nphp artisan up<\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>\u74b0\u5883\u56fa\u6709\u306e\u8003\u616e\u4e8b\u9805<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class AddIndexesToLargeTable extends Migration\n{\n    public function up()\n    {\n        \/\/ \u672c\u756a\u74b0\u5883\u3067\u306e\u5b9f\u884c\u6642\u306e\u7279\u5225\u306a\u8003\u616e\n        if (app()-&gt;environment('production')) {\n            \/\/ \u30d0\u30c3\u30c1\u30b5\u30a4\u30ba\u306e\u8abf\u6574\n            DB::statement('SET SESSION sort_buffer_size = 1024 * 1024 * 1024');\n\n            \/\/ \u6bb5\u968e\u7684\u306a\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u4f5c\u6210\n            Schema::table('large_table', function (Blueprint $table) {\n                $table-&gt;index('column_1', null, 'concurrently');\n                $table-&gt;index('column_2', null, 'concurrently');\n            });\n        } else {\n            \/\/ \u958b\u767a\u74b0\u5883\u3067\u306f\u901a\u5e38\u306e\u65b9\u6cd5\u3067\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f5c\u6210\n            Schema::table('large_table', function (Blueprint $table) {\n                $table-&gt;index(['column_1', 'column_2']);\n            });\n        }\n    }\n}<\/pre>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30d9\u30b9\u30c8\u30d7\u30e9\u30af\u30c6\u30a3\u30b9\u3092\u9069\u5207\u306b\u5b9f\u8df5\u3059\u308b\u3053\u3068\u3067\u3001\u30c1\u30fc\u30e0\u958b\u767a\u306b\u304a\u3051\u308b\u52b9\u7387\u7684\u306a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u7ba1\u7406\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002\u7279\u306b\u5927\u898f\u6a21\u306a\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u306f\u3001\u3053\u308c\u3089\u306e\u539f\u5247\u3092\u9075\u5b88\u3059\u308b\u3053\u3068\u3067\u3001\u958b\u767a\u306e\u52b9\u7387\u6027\u3068\u54c1\u8cea\u306e\u4e21\u65b9\u3092\u7dad\u6301\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Warning: Undefined array key &#8220;is_admin&#8221; in \/home\/xs392991\/dexall.co.jp\/public_html\/articles\/wp-content\/themes\/ &#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":{"0":"post-2649","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-php","7":"nothumb"},"_links":{"self":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2649"}],"version-history":[{"count":2,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2649\/revisions"}],"predecessor-version":[{"id":2651,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=\/wp\/v2\/posts\/2649\/revisions\/2651"}],"wp:attachment":[{"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dexall.co.jp\/articles\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}