[{"data":1,"prerenderedAt":1677},["ShallowReactive",2],{"content-query-tEzfrpGJUT":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"category":5,"createdAt":10,"updatedAt":10,"body":11,"_type":1671,"_id":1672,"_source":1673,"_file":1674,"_stem":1675,"_extension":1676},"/article/coding/resolve-error-from-phpunit-and-sqlite-by-refresh-database-in-laravel","coding",false,"","解決在 Laravel 使用 PHPUnit + SQLite 的 RefreshDatabase 失敗問題","之前在做單元測試需要用到 RefreshDatabase 的時候，專案內部分的 migration 會讓 SQLite 噴錯無法順利執行，以下紀錄解決方法:","2024-05-10",{"type":12,"children":13,"toc":1667},"root",[14,21,28,40,199,204,212,227,237,1323,1329,1338,1504,1508,1516,1521,1661],{"type":15,"tag":16,"props":17,"children":18},"element","p",{},[19],{"type":20,"value":9},"text",{"type":15,"tag":22,"props":23,"children":25},"h2",{"id":24},"_1-sqlite-無法使用-drop-foreign-key",[26],{"type":20,"value":27},"1. SQLite 無法使用 drop foreign key",{"type":15,"tag":16,"props":29,"children":30},{},[31,38],{"type":15,"tag":32,"props":33,"children":35},"code",{"className":34},[],[36],{"type":20,"value":37},"database/migrations/xxx.php",{"type":20,"value":39},":",{"type":15,"tag":41,"props":42,"children":46},"pre",{"code":43,"language":44,"meta":7,"className":45,"style":7},"Schema::table('users', function(Blueprint $table) {\n    // ...\n    $table->dropForeign(['role_id']);\n});\n\n","php","language-php shiki shiki-themes material-theme-palenight",[47],{"type":15,"tag":32,"props":48,"children":49},{"__ignoreMap":7},[50,134,144,190],{"type":15,"tag":51,"props":52,"children":55},"span",{"class":53,"line":54},"line",1,[56,62,68,74,79,84,90,94,99,105,109,114,119,124,129],{"type":15,"tag":51,"props":57,"children":59},{"style":58},"--shiki-default:#FFCB6B",[60],{"type":20,"value":61},"Schema",{"type":15,"tag":51,"props":63,"children":65},{"style":64},"--shiki-default:#89DDFF",[66],{"type":20,"value":67},"::",{"type":15,"tag":51,"props":69,"children":71},{"style":70},"--shiki-default:#82AAFF",[72],{"type":20,"value":73},"table",{"type":15,"tag":51,"props":75,"children":76},{"style":64},[77],{"type":20,"value":78},"(",{"type":15,"tag":51,"props":80,"children":81},{"style":64},[82],{"type":20,"value":83},"'",{"type":15,"tag":51,"props":85,"children":87},{"style":86},"--shiki-default:#C3E88D",[88],{"type":20,"value":89},"users",{"type":15,"tag":51,"props":91,"children":92},{"style":64},[93],{"type":20,"value":83},{"type":15,"tag":51,"props":95,"children":96},{"style":64},[97],{"type":20,"value":98},",",{"type":15,"tag":51,"props":100,"children":102},{"style":101},"--shiki-default:#C792EA",[103],{"type":20,"value":104}," function",{"type":15,"tag":51,"props":106,"children":107},{"style":64},[108],{"type":20,"value":78},{"type":15,"tag":51,"props":110,"children":111},{"style":58},[112],{"type":20,"value":113},"Blueprint",{"type":15,"tag":51,"props":115,"children":116},{"style":64},[117],{"type":20,"value":118}," $",{"type":15,"tag":51,"props":120,"children":122},{"style":121},"--shiki-default:#BABED8",[123],{"type":20,"value":73},{"type":15,"tag":51,"props":125,"children":126},{"style":64},[127],{"type":20,"value":128},")",{"type":15,"tag":51,"props":130,"children":131},{"style":64},[132],{"type":20,"value":133}," {\n",{"type":15,"tag":51,"props":135,"children":137},{"class":53,"line":136},2,[138],{"type":15,"tag":51,"props":139,"children":141},{"style":140},"--shiki-default:#676E95;--shiki-default-font-style:italic",[142],{"type":20,"value":143},"    // ...\n",{"type":15,"tag":51,"props":145,"children":147},{"class":53,"line":146},3,[148,153,157,162,167,172,176,181,185],{"type":15,"tag":51,"props":149,"children":150},{"style":64},[151],{"type":20,"value":152},"    $",{"type":15,"tag":51,"props":154,"children":155},{"style":121},[156],{"type":20,"value":73},{"type":15,"tag":51,"props":158,"children":159},{"style":64},[160],{"type":20,"value":161},"->",{"type":15,"tag":51,"props":163,"children":164},{"style":70},[165],{"type":20,"value":166},"dropForeign",{"type":15,"tag":51,"props":168,"children":169},{"style":64},[170],{"type":20,"value":171},"([",{"type":15,"tag":51,"props":173,"children":174},{"style":64},[175],{"type":20,"value":83},{"type":15,"tag":51,"props":177,"children":178},{"style":86},[179],{"type":20,"value":180},"role_id",{"type":15,"tag":51,"props":182,"children":183},{"style":64},[184],{"type":20,"value":83},{"type":15,"tag":51,"props":186,"children":187},{"style":64},[188],{"type":20,"value":189},"]);\n",{"type":15,"tag":51,"props":191,"children":193},{"class":53,"line":192},4,[194],{"type":15,"tag":51,"props":195,"children":196},{"style":64},[197],{"type":20,"value":198},"});\n",{"type":15,"tag":16,"props":200,"children":201},{},[202],{"type":20,"value":203},"錯誤訊息:",{"type":15,"tag":41,"props":205,"children":207},{"code":206},"BadMethodCallException: SQLite doesn't support dropping foreign keys (you would need to re-create the table).\n",[208],{"type":15,"tag":32,"props":209,"children":210},{"__ignoreMap":7},[211],{"type":20,"value":206},{"type":15,"tag":16,"props":213,"children":214},{},[215,217],{"type":20,"value":216},"解法參考: ",{"type":15,"tag":218,"props":219,"children":224},"a",{"href":220,"rel":221,"target":223},"https://github.com/laravel/framework/issues/25475",[222],"nofollow","_blank",[225],{"type":20,"value":226},"GitHub Laravel Issue",{"type":15,"tag":16,"props":228,"children":229},{},[230,236],{"type":15,"tag":32,"props":231,"children":233},{"className":232},[],[234],{"type":20,"value":235},"tests/TestCase.php",{"type":20,"value":39},{"type":15,"tag":41,"props":238,"children":240},{"code":239,"language":44,"meta":7,"className":45,"style":7},"\u003C?php\n\nnamespace Tests;\n\nuse Closure;\nuse Illuminate\\Database\\Connection;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Database\\Schema\\SQLiteBuilder;\nuse Illuminate\\Database\\SQLiteConnection;\nuse Illuminate\\Foundation\\Testing\\RefreshDatabase;\nuse Illuminate\\Foundation\\Testing\\TestCase as BaseTestCase;\n\nabstract class TestCase extends BaseTestCase\n{\n    use CreatesApplication;\n    use RefreshDatabase;\n\n    public function __construct()\n    {\n        parent::__construct();\n        $this->withoutForeign();\n    }\n\n    private function withoutForeign()\n    {\n        Connection::resolverFor('sqlite', function ($connection, $database, $prefix, $config) {\n            return new class($connection, $database, $prefix, $config) extends SQLiteConnection\n            {\n                public function getSchemaBuilder()\n                {\n                    if ($this->schemaGrammar === null) {\n                        $this->useDefaultSchemaGrammar();\n                    }\n                    return new class($this) extends SQLiteBuilder\n                    {\n                        protected function createBlueprint($table, Closure $callback = null)\n                        {\n                            return new class($table, $callback) extends Blueprint\n                            {\n                                public function dropForeign($index)\n                                {\n                                }\n                            };\n                        }\n                    };\n                }\n            };\n        });\n    }\n}\n\n",[241],{"type":15,"tag":32,"props":242,"children":243},{"__ignoreMap":7},[244,257,266,285,292,310,346,386,427,460,503,554,562,591,600,618,635,643,666,675,698,716,725,733,755,763,863,940,949,971,980,1013,1031,1040,1071,1080,1133,1142,1193,1202,1234,1243,1252,1261,1270,1279,1288,1297,1306,1314],{"type":15,"tag":51,"props":245,"children":246},{"class":53,"line":54},[247,252],{"type":15,"tag":51,"props":248,"children":249},{"style":64},[250],{"type":20,"value":251},"\u003C?",{"type":15,"tag":51,"props":253,"children":254},{"style":121},[255],{"type":20,"value":256},"php\n",{"type":15,"tag":51,"props":258,"children":259},{"class":53,"line":136},[260],{"type":15,"tag":51,"props":261,"children":263},{"emptyLinePlaceholder":262},true,[264],{"type":20,"value":265},"\n",{"type":15,"tag":51,"props":267,"children":268},{"class":53,"line":146},[269,275,280],{"type":15,"tag":51,"props":270,"children":272},{"style":271},"--shiki-default:#F78C6C",[273],{"type":20,"value":274},"namespace",{"type":15,"tag":51,"props":276,"children":277},{"style":58},[278],{"type":20,"value":279}," Tests",{"type":15,"tag":51,"props":281,"children":282},{"style":64},[283],{"type":20,"value":284},";\n",{"type":15,"tag":51,"props":286,"children":287},{"class":53,"line":192},[288],{"type":15,"tag":51,"props":289,"children":290},{"emptyLinePlaceholder":262},[291],{"type":20,"value":265},{"type":15,"tag":51,"props":293,"children":295},{"class":53,"line":294},5,[296,301,306],{"type":15,"tag":51,"props":297,"children":298},{"style":271},[299],{"type":20,"value":300},"use",{"type":15,"tag":51,"props":302,"children":303},{"style":121},[304],{"type":20,"value":305}," Closure",{"type":15,"tag":51,"props":307,"children":308},{"style":64},[309],{"type":20,"value":284},{"type":15,"tag":51,"props":311,"children":313},{"class":53,"line":312},6,[314,318,323,328,333,337,342],{"type":15,"tag":51,"props":315,"children":316},{"style":271},[317],{"type":20,"value":300},{"type":15,"tag":51,"props":319,"children":320},{"style":121},[321],{"type":20,"value":322}," Illuminate",{"type":15,"tag":51,"props":324,"children":325},{"style":64},[326],{"type":20,"value":327},"\\",{"type":15,"tag":51,"props":329,"children":330},{"style":121},[331],{"type":20,"value":332},"Database",{"type":15,"tag":51,"props":334,"children":335},{"style":64},[336],{"type":20,"value":327},{"type":15,"tag":51,"props":338,"children":339},{"style":121},[340],{"type":20,"value":341},"Connection",{"type":15,"tag":51,"props":343,"children":344},{"style":64},[345],{"type":20,"value":284},{"type":15,"tag":51,"props":347,"children":349},{"class":53,"line":348},7,[350,354,358,362,366,370,374,378,382],{"type":15,"tag":51,"props":351,"children":352},{"style":271},[353],{"type":20,"value":300},{"type":15,"tag":51,"props":355,"children":356},{"style":121},[357],{"type":20,"value":322},{"type":15,"tag":51,"props":359,"children":360},{"style":64},[361],{"type":20,"value":327},{"type":15,"tag":51,"props":363,"children":364},{"style":121},[365],{"type":20,"value":332},{"type":15,"tag":51,"props":367,"children":368},{"style":64},[369],{"type":20,"value":327},{"type":15,"tag":51,"props":371,"children":372},{"style":121},[373],{"type":20,"value":61},{"type":15,"tag":51,"props":375,"children":376},{"style":64},[377],{"type":20,"value":327},{"type":15,"tag":51,"props":379,"children":380},{"style":121},[381],{"type":20,"value":113},{"type":15,"tag":51,"props":383,"children":384},{"style":64},[385],{"type":20,"value":284},{"type":15,"tag":51,"props":387,"children":389},{"class":53,"line":388},8,[390,394,398,402,406,410,414,418,423],{"type":15,"tag":51,"props":391,"children":392},{"style":271},[393],{"type":20,"value":300},{"type":15,"tag":51,"props":395,"children":396},{"style":121},[397],{"type":20,"value":322},{"type":15,"tag":51,"props":399,"children":400},{"style":64},[401],{"type":20,"value":327},{"type":15,"tag":51,"props":403,"children":404},{"style":121},[405],{"type":20,"value":332},{"type":15,"tag":51,"props":407,"children":408},{"style":64},[409],{"type":20,"value":327},{"type":15,"tag":51,"props":411,"children":412},{"style":121},[413],{"type":20,"value":61},{"type":15,"tag":51,"props":415,"children":416},{"style":64},[417],{"type":20,"value":327},{"type":15,"tag":51,"props":419,"children":420},{"style":121},[421],{"type":20,"value":422},"SQLiteBuilder",{"type":15,"tag":51,"props":424,"children":425},{"style":64},[426],{"type":20,"value":284},{"type":15,"tag":51,"props":428,"children":430},{"class":53,"line":429},9,[431,435,439,443,447,451,456],{"type":15,"tag":51,"props":432,"children":433},{"style":271},[434],{"type":20,"value":300},{"type":15,"tag":51,"props":436,"children":437},{"style":121},[438],{"type":20,"value":322},{"type":15,"tag":51,"props":440,"children":441},{"style":64},[442],{"type":20,"value":327},{"type":15,"tag":51,"props":444,"children":445},{"style":121},[446],{"type":20,"value":332},{"type":15,"tag":51,"props":448,"children":449},{"style":64},[450],{"type":20,"value":327},{"type":15,"tag":51,"props":452,"children":453},{"style":121},[454],{"type":20,"value":455},"SQLiteConnection",{"type":15,"tag":51,"props":457,"children":458},{"style":64},[459],{"type":20,"value":284},{"type":15,"tag":51,"props":461,"children":463},{"class":53,"line":462},10,[464,468,472,476,481,485,490,494,499],{"type":15,"tag":51,"props":465,"children":466},{"style":271},[467],{"type":20,"value":300},{"type":15,"tag":51,"props":469,"children":470},{"style":121},[471],{"type":20,"value":322},{"type":15,"tag":51,"props":473,"children":474},{"style":64},[475],{"type":20,"value":327},{"type":15,"tag":51,"props":477,"children":478},{"style":121},[479],{"type":20,"value":480},"Foundation",{"type":15,"tag":51,"props":482,"children":483},{"style":64},[484],{"type":20,"value":327},{"type":15,"tag":51,"props":486,"children":487},{"style":121},[488],{"type":20,"value":489},"Testing",{"type":15,"tag":51,"props":491,"children":492},{"style":64},[493],{"type":20,"value":327},{"type":15,"tag":51,"props":495,"children":496},{"style":121},[497],{"type":20,"value":498},"RefreshDatabase",{"type":15,"tag":51,"props":500,"children":501},{"style":64},[502],{"type":20,"value":284},{"type":15,"tag":51,"props":504,"children":506},{"class":53,"line":505},11,[507,511,515,519,523,527,531,535,540,545,550],{"type":15,"tag":51,"props":508,"children":509},{"style":271},[510],{"type":20,"value":300},{"type":15,"tag":51,"props":512,"children":513},{"style":121},[514],{"type":20,"value":322},{"type":15,"tag":51,"props":516,"children":517},{"style":64},[518],{"type":20,"value":327},{"type":15,"tag":51,"props":520,"children":521},{"style":121},[522],{"type":20,"value":480},{"type":15,"tag":51,"props":524,"children":525},{"style":64},[526],{"type":20,"value":327},{"type":15,"tag":51,"props":528,"children":529},{"style":121},[530],{"type":20,"value":489},{"type":15,"tag":51,"props":532,"children":533},{"style":64},[534],{"type":20,"value":327},{"type":15,"tag":51,"props":536,"children":537},{"style":121},[538],{"type":20,"value":539},"TestCase",{"type":15,"tag":51,"props":541,"children":542},{"style":271},[543],{"type":20,"value":544}," as",{"type":15,"tag":51,"props":546,"children":547},{"style":58},[548],{"type":20,"value":549}," BaseTestCase",{"type":15,"tag":51,"props":551,"children":552},{"style":64},[553],{"type":20,"value":284},{"type":15,"tag":51,"props":555,"children":557},{"class":53,"line":556},12,[558],{"type":15,"tag":51,"props":559,"children":560},{"emptyLinePlaceholder":262},[561],{"type":20,"value":265},{"type":15,"tag":51,"props":563,"children":565},{"class":53,"line":564},13,[566,571,576,581,586],{"type":15,"tag":51,"props":567,"children":568},{"style":101},[569],{"type":20,"value":570},"abstract",{"type":15,"tag":51,"props":572,"children":573},{"style":101},[574],{"type":20,"value":575}," class",{"type":15,"tag":51,"props":577,"children":578},{"style":58},[579],{"type":20,"value":580}," TestCase",{"type":15,"tag":51,"props":582,"children":583},{"style":101},[584],{"type":20,"value":585}," extends",{"type":15,"tag":51,"props":587,"children":588},{"style":58},[589],{"type":20,"value":590}," BaseTestCase\n",{"type":15,"tag":51,"props":592,"children":594},{"class":53,"line":593},14,[595],{"type":15,"tag":51,"props":596,"children":597},{"style":64},[598],{"type":20,"value":599},"{\n",{"type":15,"tag":51,"props":601,"children":603},{"class":53,"line":602},15,[604,609,614],{"type":15,"tag":51,"props":605,"children":606},{"style":271},[607],{"type":20,"value":608},"    use",{"type":15,"tag":51,"props":610,"children":611},{"style":121},[612],{"type":20,"value":613}," CreatesApplication",{"type":15,"tag":51,"props":615,"children":616},{"style":64},[617],{"type":20,"value":284},{"type":15,"tag":51,"props":619,"children":621},{"class":53,"line":620},16,[622,626,631],{"type":15,"tag":51,"props":623,"children":624},{"style":271},[625],{"type":20,"value":608},{"type":15,"tag":51,"props":627,"children":628},{"style":121},[629],{"type":20,"value":630}," RefreshDatabase",{"type":15,"tag":51,"props":632,"children":633},{"style":64},[634],{"type":20,"value":284},{"type":15,"tag":51,"props":636,"children":638},{"class":53,"line":637},17,[639],{"type":15,"tag":51,"props":640,"children":641},{"emptyLinePlaceholder":262},[642],{"type":20,"value":265},{"type":15,"tag":51,"props":644,"children":646},{"class":53,"line":645},18,[647,652,656,661],{"type":15,"tag":51,"props":648,"children":649},{"style":101},[650],{"type":20,"value":651},"    public",{"type":15,"tag":51,"props":653,"children":654},{"style":101},[655],{"type":20,"value":104},{"type":15,"tag":51,"props":657,"children":658},{"style":70},[659],{"type":20,"value":660}," __construct",{"type":15,"tag":51,"props":662,"children":663},{"style":64},[664],{"type":20,"value":665},"()\n",{"type":15,"tag":51,"props":667,"children":669},{"class":53,"line":668},19,[670],{"type":15,"tag":51,"props":671,"children":672},{"style":64},[673],{"type":20,"value":674},"    {\n",{"type":15,"tag":51,"props":676,"children":678},{"class":53,"line":677},20,[679,684,688,693],{"type":15,"tag":51,"props":680,"children":681},{"style":101},[682],{"type":20,"value":683},"        parent",{"type":15,"tag":51,"props":685,"children":686},{"style":64},[687],{"type":20,"value":67},{"type":15,"tag":51,"props":689,"children":690},{"style":70},[691],{"type":20,"value":692},"__construct",{"type":15,"tag":51,"props":694,"children":695},{"style":64},[696],{"type":20,"value":697},"();\n",{"type":15,"tag":51,"props":699,"children":701},{"class":53,"line":700},21,[702,707,712],{"type":15,"tag":51,"props":703,"children":704},{"style":64},[705],{"type":20,"value":706},"        $this->",{"type":15,"tag":51,"props":708,"children":709},{"style":70},[710],{"type":20,"value":711},"withoutForeign",{"type":15,"tag":51,"props":713,"children":714},{"style":64},[715],{"type":20,"value":697},{"type":15,"tag":51,"props":717,"children":719},{"class":53,"line":718},22,[720],{"type":15,"tag":51,"props":721,"children":722},{"style":64},[723],{"type":20,"value":724},"    }\n",{"type":15,"tag":51,"props":726,"children":728},{"class":53,"line":727},23,[729],{"type":15,"tag":51,"props":730,"children":731},{"emptyLinePlaceholder":262},[732],{"type":20,"value":265},{"type":15,"tag":51,"props":734,"children":736},{"class":53,"line":735},24,[737,742,746,751],{"type":15,"tag":51,"props":738,"children":739},{"style":101},[740],{"type":20,"value":741},"    private",{"type":15,"tag":51,"props":743,"children":744},{"style":101},[745],{"type":20,"value":104},{"type":15,"tag":51,"props":747,"children":748},{"style":70},[749],{"type":20,"value":750}," withoutForeign",{"type":15,"tag":51,"props":752,"children":753},{"style":64},[754],{"type":20,"value":665},{"type":15,"tag":51,"props":756,"children":758},{"class":53,"line":757},25,[759],{"type":15,"tag":51,"props":760,"children":761},{"style":64},[762],{"type":20,"value":674},{"type":15,"tag":51,"props":764,"children":766},{"class":53,"line":765},26,[767,772,776,781,785,789,794,798,802,806,811,816,820,824,829,833,837,842,846,850,855,859],{"type":15,"tag":51,"props":768,"children":769},{"style":58},[770],{"type":20,"value":771},"        Connection",{"type":15,"tag":51,"props":773,"children":774},{"style":64},[775],{"type":20,"value":67},{"type":15,"tag":51,"props":777,"children":778},{"style":70},[779],{"type":20,"value":780},"resolverFor",{"type":15,"tag":51,"props":782,"children":783},{"style":64},[784],{"type":20,"value":78},{"type":15,"tag":51,"props":786,"children":787},{"style":64},[788],{"type":20,"value":83},{"type":15,"tag":51,"props":790,"children":791},{"style":86},[792],{"type":20,"value":793},"sqlite",{"type":15,"tag":51,"props":795,"children":796},{"style":64},[797],{"type":20,"value":83},{"type":15,"tag":51,"props":799,"children":800},{"style":64},[801],{"type":20,"value":98},{"type":15,"tag":51,"props":803,"children":804},{"style":101},[805],{"type":20,"value":104},{"type":15,"tag":51,"props":807,"children":808},{"style":64},[809],{"type":20,"value":810}," ($",{"type":15,"tag":51,"props":812,"children":813},{"style":121},[814],{"type":20,"value":815},"connection",{"type":15,"tag":51,"props":817,"children":818},{"style":64},[819],{"type":20,"value":98},{"type":15,"tag":51,"props":821,"children":822},{"style":64},[823],{"type":20,"value":118},{"type":15,"tag":51,"props":825,"children":826},{"style":121},[827],{"type":20,"value":828},"database",{"type":15,"tag":51,"props":830,"children":831},{"style":64},[832],{"type":20,"value":98},{"type":15,"tag":51,"props":834,"children":835},{"style":64},[836],{"type":20,"value":118},{"type":15,"tag":51,"props":838,"children":839},{"style":121},[840],{"type":20,"value":841},"prefix",{"type":15,"tag":51,"props":843,"children":844},{"style":64},[845],{"type":20,"value":98},{"type":15,"tag":51,"props":847,"children":848},{"style":64},[849],{"type":20,"value":118},{"type":15,"tag":51,"props":851,"children":852},{"style":121},[853],{"type":20,"value":854},"config",{"type":15,"tag":51,"props":856,"children":857},{"style":64},[858],{"type":20,"value":128},{"type":15,"tag":51,"props":860,"children":861},{"style":64},[862],{"type":20,"value":133},{"type":15,"tag":51,"props":864,"children":866},{"class":53,"line":865},27,[867,873,878,882,887,891,895,899,903,907,911,915,919,923,927,931,935],{"type":15,"tag":51,"props":868,"children":870},{"style":869},"--shiki-default:#89DDFF;--shiki-default-font-style:italic",[871],{"type":20,"value":872},"            return",{"type":15,"tag":51,"props":874,"children":875},{"style":271},[876],{"type":20,"value":877}," new",{"type":15,"tag":51,"props":879,"children":880},{"style":101},[881],{"type":20,"value":575},{"type":15,"tag":51,"props":883,"children":884},{"style":64},[885],{"type":20,"value":886},"($",{"type":15,"tag":51,"props":888,"children":889},{"style":121},[890],{"type":20,"value":815},{"type":15,"tag":51,"props":892,"children":893},{"style":64},[894],{"type":20,"value":98},{"type":15,"tag":51,"props":896,"children":897},{"style":64},[898],{"type":20,"value":118},{"type":15,"tag":51,"props":900,"children":901},{"style":121},[902],{"type":20,"value":828},{"type":15,"tag":51,"props":904,"children":905},{"style":64},[906],{"type":20,"value":98},{"type":15,"tag":51,"props":908,"children":909},{"style":64},[910],{"type":20,"value":118},{"type":15,"tag":51,"props":912,"children":913},{"style":121},[914],{"type":20,"value":841},{"type":15,"tag":51,"props":916,"children":917},{"style":64},[918],{"type":20,"value":98},{"type":15,"tag":51,"props":920,"children":921},{"style":64},[922],{"type":20,"value":118},{"type":15,"tag":51,"props":924,"children":925},{"style":121},[926],{"type":20,"value":854},{"type":15,"tag":51,"props":928,"children":929},{"style":64},[930],{"type":20,"value":128},{"type":15,"tag":51,"props":932,"children":933},{"style":101},[934],{"type":20,"value":585},{"type":15,"tag":51,"props":936,"children":937},{"style":58},[938],{"type":20,"value":939}," SQLiteConnection\n",{"type":15,"tag":51,"props":941,"children":943},{"class":53,"line":942},28,[944],{"type":15,"tag":51,"props":945,"children":946},{"style":64},[947],{"type":20,"value":948},"            {\n",{"type":15,"tag":51,"props":950,"children":952},{"class":53,"line":951},29,[953,958,962,967],{"type":15,"tag":51,"props":954,"children":955},{"style":101},[956],{"type":20,"value":957},"                public",{"type":15,"tag":51,"props":959,"children":960},{"style":101},[961],{"type":20,"value":104},{"type":15,"tag":51,"props":963,"children":964},{"style":70},[965],{"type":20,"value":966}," getSchemaBuilder",{"type":15,"tag":51,"props":968,"children":969},{"style":64},[970],{"type":20,"value":665},{"type":15,"tag":51,"props":972,"children":974},{"class":53,"line":973},30,[975],{"type":15,"tag":51,"props":976,"children":977},{"style":64},[978],{"type":20,"value":979},"                {\n",{"type":15,"tag":51,"props":981,"children":983},{"class":53,"line":982},31,[984,989,994,999,1004,1009],{"type":15,"tag":51,"props":985,"children":986},{"style":869},[987],{"type":20,"value":988},"                    if",{"type":15,"tag":51,"props":990,"children":991},{"style":64},[992],{"type":20,"value":993}," ($this->",{"type":15,"tag":51,"props":995,"children":996},{"style":121},[997],{"type":20,"value":998},"schemaGrammar ",{"type":15,"tag":51,"props":1000,"children":1001},{"style":64},[1002],{"type":20,"value":1003},"===",{"type":15,"tag":51,"props":1005,"children":1006},{"style":64},[1007],{"type":20,"value":1008}," null)",{"type":15,"tag":51,"props":1010,"children":1011},{"style":64},[1012],{"type":20,"value":133},{"type":15,"tag":51,"props":1014,"children":1016},{"class":53,"line":1015},32,[1017,1022,1027],{"type":15,"tag":51,"props":1018,"children":1019},{"style":64},[1020],{"type":20,"value":1021},"                        $this->",{"type":15,"tag":51,"props":1023,"children":1024},{"style":70},[1025],{"type":20,"value":1026},"useDefaultSchemaGrammar",{"type":15,"tag":51,"props":1028,"children":1029},{"style":64},[1030],{"type":20,"value":697},{"type":15,"tag":51,"props":1032,"children":1034},{"class":53,"line":1033},33,[1035],{"type":15,"tag":51,"props":1036,"children":1037},{"style":64},[1038],{"type":20,"value":1039},"                    }\n",{"type":15,"tag":51,"props":1041,"children":1043},{"class":53,"line":1042},34,[1044,1049,1053,1057,1062,1066],{"type":15,"tag":51,"props":1045,"children":1046},{"style":869},[1047],{"type":20,"value":1048},"                    return",{"type":15,"tag":51,"props":1050,"children":1051},{"style":271},[1052],{"type":20,"value":877},{"type":15,"tag":51,"props":1054,"children":1055},{"style":101},[1056],{"type":20,"value":575},{"type":15,"tag":51,"props":1058,"children":1059},{"style":64},[1060],{"type":20,"value":1061},"($this)",{"type":15,"tag":51,"props":1063,"children":1064},{"style":101},[1065],{"type":20,"value":585},{"type":15,"tag":51,"props":1067,"children":1068},{"style":58},[1069],{"type":20,"value":1070}," SQLiteBuilder\n",{"type":15,"tag":51,"props":1072,"children":1074},{"class":53,"line":1073},35,[1075],{"type":15,"tag":51,"props":1076,"children":1077},{"style":64},[1078],{"type":20,"value":1079},"                    {\n",{"type":15,"tag":51,"props":1081,"children":1083},{"class":53,"line":1082},36,[1084,1089,1093,1098,1102,1106,1110,1114,1118,1123,1128],{"type":15,"tag":51,"props":1085,"children":1086},{"style":101},[1087],{"type":20,"value":1088},"                        protected",{"type":15,"tag":51,"props":1090,"children":1091},{"style":101},[1092],{"type":20,"value":104},{"type":15,"tag":51,"props":1094,"children":1095},{"style":70},[1096],{"type":20,"value":1097}," createBlueprint",{"type":15,"tag":51,"props":1099,"children":1100},{"style":64},[1101],{"type":20,"value":886},{"type":15,"tag":51,"props":1103,"children":1104},{"style":121},[1105],{"type":20,"value":73},{"type":15,"tag":51,"props":1107,"children":1108},{"style":64},[1109],{"type":20,"value":98},{"type":15,"tag":51,"props":1111,"children":1112},{"style":58},[1113],{"type":20,"value":305},{"type":15,"tag":51,"props":1115,"children":1116},{"style":64},[1117],{"type":20,"value":118},{"type":15,"tag":51,"props":1119,"children":1120},{"style":121},[1121],{"type":20,"value":1122},"callback ",{"type":15,"tag":51,"props":1124,"children":1125},{"style":64},[1126],{"type":20,"value":1127},"=",{"type":15,"tag":51,"props":1129,"children":1130},{"style":64},[1131],{"type":20,"value":1132}," null)\n",{"type":15,"tag":51,"props":1134,"children":1136},{"class":53,"line":1135},37,[1137],{"type":15,"tag":51,"props":1138,"children":1139},{"style":64},[1140],{"type":20,"value":1141},"                        {\n",{"type":15,"tag":51,"props":1143,"children":1145},{"class":53,"line":1144},38,[1146,1151,1155,1159,1163,1167,1171,1175,1180,1184,1188],{"type":15,"tag":51,"props":1147,"children":1148},{"style":869},[1149],{"type":20,"value":1150},"                            return",{"type":15,"tag":51,"props":1152,"children":1153},{"style":271},[1154],{"type":20,"value":877},{"type":15,"tag":51,"props":1156,"children":1157},{"style":101},[1158],{"type":20,"value":575},{"type":15,"tag":51,"props":1160,"children":1161},{"style":64},[1162],{"type":20,"value":886},{"type":15,"tag":51,"props":1164,"children":1165},{"style":121},[1166],{"type":20,"value":73},{"type":15,"tag":51,"props":1168,"children":1169},{"style":64},[1170],{"type":20,"value":98},{"type":15,"tag":51,"props":1172,"children":1173},{"style":64},[1174],{"type":20,"value":118},{"type":15,"tag":51,"props":1176,"children":1177},{"style":121},[1178],{"type":20,"value":1179},"callback",{"type":15,"tag":51,"props":1181,"children":1182},{"style":64},[1183],{"type":20,"value":128},{"type":15,"tag":51,"props":1185,"children":1186},{"style":101},[1187],{"type":20,"value":585},{"type":15,"tag":51,"props":1189,"children":1190},{"style":58},[1191],{"type":20,"value":1192}," Blueprint\n",{"type":15,"tag":51,"props":1194,"children":1196},{"class":53,"line":1195},39,[1197],{"type":15,"tag":51,"props":1198,"children":1199},{"style":64},[1200],{"type":20,"value":1201},"                            {\n",{"type":15,"tag":51,"props":1203,"children":1205},{"class":53,"line":1204},40,[1206,1211,1215,1220,1224,1229],{"type":15,"tag":51,"props":1207,"children":1208},{"style":101},[1209],{"type":20,"value":1210},"                                public",{"type":15,"tag":51,"props":1212,"children":1213},{"style":101},[1214],{"type":20,"value":104},{"type":15,"tag":51,"props":1216,"children":1217},{"style":70},[1218],{"type":20,"value":1219}," dropForeign",{"type":15,"tag":51,"props":1221,"children":1222},{"style":64},[1223],{"type":20,"value":886},{"type":15,"tag":51,"props":1225,"children":1226},{"style":121},[1227],{"type":20,"value":1228},"index",{"type":15,"tag":51,"props":1230,"children":1231},{"style":64},[1232],{"type":20,"value":1233},")\n",{"type":15,"tag":51,"props":1235,"children":1237},{"class":53,"line":1236},41,[1238],{"type":15,"tag":51,"props":1239,"children":1240},{"style":64},[1241],{"type":20,"value":1242},"                                {\n",{"type":15,"tag":51,"props":1244,"children":1246},{"class":53,"line":1245},42,[1247],{"type":15,"tag":51,"props":1248,"children":1249},{"style":64},[1250],{"type":20,"value":1251},"                                }\n",{"type":15,"tag":51,"props":1253,"children":1255},{"class":53,"line":1254},43,[1256],{"type":15,"tag":51,"props":1257,"children":1258},{"style":64},[1259],{"type":20,"value":1260},"                            };\n",{"type":15,"tag":51,"props":1262,"children":1264},{"class":53,"line":1263},44,[1265],{"type":15,"tag":51,"props":1266,"children":1267},{"style":64},[1268],{"type":20,"value":1269},"                        }\n",{"type":15,"tag":51,"props":1271,"children":1273},{"class":53,"line":1272},45,[1274],{"type":15,"tag":51,"props":1275,"children":1276},{"style":64},[1277],{"type":20,"value":1278},"                    };\n",{"type":15,"tag":51,"props":1280,"children":1282},{"class":53,"line":1281},46,[1283],{"type":15,"tag":51,"props":1284,"children":1285},{"style":64},[1286],{"type":20,"value":1287},"                }\n",{"type":15,"tag":51,"props":1289,"children":1291},{"class":53,"line":1290},47,[1292],{"type":15,"tag":51,"props":1293,"children":1294},{"style":64},[1295],{"type":20,"value":1296},"            };\n",{"type":15,"tag":51,"props":1298,"children":1300},{"class":53,"line":1299},48,[1301],{"type":15,"tag":51,"props":1302,"children":1303},{"style":64},[1304],{"type":20,"value":1305},"        });\n",{"type":15,"tag":51,"props":1307,"children":1309},{"class":53,"line":1308},49,[1310],{"type":15,"tag":51,"props":1311,"children":1312},{"style":64},[1313],{"type":20,"value":724},{"type":15,"tag":51,"props":1315,"children":1317},{"class":53,"line":1316},50,[1318],{"type":15,"tag":51,"props":1319,"children":1320},{"style":64},[1321],{"type":20,"value":1322},"}\n",{"type":15,"tag":22,"props":1324,"children":1326},{"id":1325},"_2-在-sqlite-顯示無法-dropcolumn",[1327],{"type":20,"value":1328},"2. 在 SQLite 顯示無法 dropColumn",{"type":15,"tag":16,"props":1330,"children":1331},{},[1332,1337],{"type":15,"tag":32,"props":1333,"children":1335},{"className":1334},[],[1336],{"type":20,"value":37},{"type":20,"value":39},{"type":15,"tag":41,"props":1339,"children":1341},{"code":1340,"language":44,"meta":7,"className":45,"style":7},"Schema::table('users', function(Blueprint $table) {\n    // ...\n    $table->dropColumn('description');\n    $table->dropColumn('deleted_at');\n});\n\n",[1342],{"type":15,"tag":32,"props":1343,"children":1344},{"__ignoreMap":7},[1345,1408,1415,1457,1497],{"type":15,"tag":51,"props":1346,"children":1347},{"class":53,"line":54},[1348,1352,1356,1360,1364,1368,1372,1376,1380,1384,1388,1392,1396,1400,1404],{"type":15,"tag":51,"props":1349,"children":1350},{"style":58},[1351],{"type":20,"value":61},{"type":15,"tag":51,"props":1353,"children":1354},{"style":64},[1355],{"type":20,"value":67},{"type":15,"tag":51,"props":1357,"children":1358},{"style":70},[1359],{"type":20,"value":73},{"type":15,"tag":51,"props":1361,"children":1362},{"style":64},[1363],{"type":20,"value":78},{"type":15,"tag":51,"props":1365,"children":1366},{"style":64},[1367],{"type":20,"value":83},{"type":15,"tag":51,"props":1369,"children":1370},{"style":86},[1371],{"type":20,"value":89},{"type":15,"tag":51,"props":1373,"children":1374},{"style":64},[1375],{"type":20,"value":83},{"type":15,"tag":51,"props":1377,"children":1378},{"style":64},[1379],{"type":20,"value":98},{"type":15,"tag":51,"props":1381,"children":1382},{"style":101},[1383],{"type":20,"value":104},{"type":15,"tag":51,"props":1385,"children":1386},{"style":64},[1387],{"type":20,"value":78},{"type":15,"tag":51,"props":1389,"children":1390},{"style":58},[1391],{"type":20,"value":113},{"type":15,"tag":51,"props":1393,"children":1394},{"style":64},[1395],{"type":20,"value":118},{"type":15,"tag":51,"props":1397,"children":1398},{"style":121},[1399],{"type":20,"value":73},{"type":15,"tag":51,"props":1401,"children":1402},{"style":64},[1403],{"type":20,"value":128},{"type":15,"tag":51,"props":1405,"children":1406},{"style":64},[1407],{"type":20,"value":133},{"type":15,"tag":51,"props":1409,"children":1410},{"class":53,"line":136},[1411],{"type":15,"tag":51,"props":1412,"children":1413},{"style":140},[1414],{"type":20,"value":143},{"type":15,"tag":51,"props":1416,"children":1417},{"class":53,"line":146},[1418,1422,1426,1430,1435,1439,1443,1448,1452],{"type":15,"tag":51,"props":1419,"children":1420},{"style":64},[1421],{"type":20,"value":152},{"type":15,"tag":51,"props":1423,"children":1424},{"style":121},[1425],{"type":20,"value":73},{"type":15,"tag":51,"props":1427,"children":1428},{"style":64},[1429],{"type":20,"value":161},{"type":15,"tag":51,"props":1431,"children":1432},{"style":70},[1433],{"type":20,"value":1434},"dropColumn",{"type":15,"tag":51,"props":1436,"children":1437},{"style":64},[1438],{"type":20,"value":78},{"type":15,"tag":51,"props":1440,"children":1441},{"style":64},[1442],{"type":20,"value":83},{"type":15,"tag":51,"props":1444,"children":1445},{"style":86},[1446],{"type":20,"value":1447},"description",{"type":15,"tag":51,"props":1449,"children":1450},{"style":64},[1451],{"type":20,"value":83},{"type":15,"tag":51,"props":1453,"children":1454},{"style":64},[1455],{"type":20,"value":1456},");\n",{"type":15,"tag":51,"props":1458,"children":1459},{"class":53,"line":192},[1460,1464,1468,1472,1476,1480,1484,1489,1493],{"type":15,"tag":51,"props":1461,"children":1462},{"style":64},[1463],{"type":20,"value":152},{"type":15,"tag":51,"props":1465,"children":1466},{"style":121},[1467],{"type":20,"value":73},{"type":15,"tag":51,"props":1469,"children":1470},{"style":64},[1471],{"type":20,"value":161},{"type":15,"tag":51,"props":1473,"children":1474},{"style":70},[1475],{"type":20,"value":1434},{"type":15,"tag":51,"props":1477,"children":1478},{"style":64},[1479],{"type":20,"value":78},{"type":15,"tag":51,"props":1481,"children":1482},{"style":64},[1483],{"type":20,"value":83},{"type":15,"tag":51,"props":1485,"children":1486},{"style":86},[1487],{"type":20,"value":1488},"deleted_at",{"type":15,"tag":51,"props":1490,"children":1491},{"style":64},[1492],{"type":20,"value":83},{"type":15,"tag":51,"props":1494,"children":1495},{"style":64},[1496],{"type":20,"value":1456},{"type":15,"tag":51,"props":1498,"children":1499},{"class":53,"line":294},[1500],{"type":15,"tag":51,"props":1501,"children":1502},{"style":64},[1503],{"type":20,"value":198},{"type":15,"tag":16,"props":1505,"children":1506},{},[1507],{"type":20,"value":203},{"type":15,"tag":41,"props":1509,"children":1511},{"code":1510},"BadMethodCallException: SQLite doesn't support multiple calls to dropColumn / renameColumn in a single modification.\n",[1512],{"type":15,"tag":32,"props":1513,"children":1514},{"__ignoreMap":7},[1515],{"type":20,"value":1510},{"type":15,"tag":16,"props":1517,"children":1518},{},[1519],{"type":20,"value":1520},"解法:\n將 migration 改為如下:",{"type":15,"tag":41,"props":1522,"children":1524},{"code":1523,"language":44,"meta":7,"className":45,"style":7},"Schema::table('users', function(Blueprint $table) {\n    // ...\n    $table->dropColumn(['description', 'deleted_at']);\n});\n\n",[1525],{"type":15,"tag":32,"props":1526,"children":1527},{"__ignoreMap":7},[1528,1591,1598,1654],{"type":15,"tag":51,"props":1529,"children":1530},{"class":53,"line":54},[1531,1535,1539,1543,1547,1551,1555,1559,1563,1567,1571,1575,1579,1583,1587],{"type":15,"tag":51,"props":1532,"children":1533},{"style":58},[1534],{"type":20,"value":61},{"type":15,"tag":51,"props":1536,"children":1537},{"style":64},[1538],{"type":20,"value":67},{"type":15,"tag":51,"props":1540,"children":1541},{"style":70},[1542],{"type":20,"value":73},{"type":15,"tag":51,"props":1544,"children":1545},{"style":64},[1546],{"type":20,"value":78},{"type":15,"tag":51,"props":1548,"children":1549},{"style":64},[1550],{"type":20,"value":83},{"type":15,"tag":51,"props":1552,"children":1553},{"style":86},[1554],{"type":20,"value":89},{"type":15,"tag":51,"props":1556,"children":1557},{"style":64},[1558],{"type":20,"value":83},{"type":15,"tag":51,"props":1560,"children":1561},{"style":64},[1562],{"type":20,"value":98},{"type":15,"tag":51,"props":1564,"children":1565},{"style":101},[1566],{"type":20,"value":104},{"type":15,"tag":51,"props":1568,"children":1569},{"style":64},[1570],{"type":20,"value":78},{"type":15,"tag":51,"props":1572,"children":1573},{"style":58},[1574],{"type":20,"value":113},{"type":15,"tag":51,"props":1576,"children":1577},{"style":64},[1578],{"type":20,"value":118},{"type":15,"tag":51,"props":1580,"children":1581},{"style":121},[1582],{"type":20,"value":73},{"type":15,"tag":51,"props":1584,"children":1585},{"style":64},[1586],{"type":20,"value":128},{"type":15,"tag":51,"props":1588,"children":1589},{"style":64},[1590],{"type":20,"value":133},{"type":15,"tag":51,"props":1592,"children":1593},{"class":53,"line":136},[1594],{"type":15,"tag":51,"props":1595,"children":1596},{"style":140},[1597],{"type":20,"value":143},{"type":15,"tag":51,"props":1599,"children":1600},{"class":53,"line":146},[1601,1605,1609,1613,1617,1621,1625,1629,1633,1637,1642,1646,1650],{"type":15,"tag":51,"props":1602,"children":1603},{"style":64},[1604],{"type":20,"value":152},{"type":15,"tag":51,"props":1606,"children":1607},{"style":121},[1608],{"type":20,"value":73},{"type":15,"tag":51,"props":1610,"children":1611},{"style":64},[1612],{"type":20,"value":161},{"type":15,"tag":51,"props":1614,"children":1615},{"style":70},[1616],{"type":20,"value":1434},{"type":15,"tag":51,"props":1618,"children":1619},{"style":64},[1620],{"type":20,"value":171},{"type":15,"tag":51,"props":1622,"children":1623},{"style":64},[1624],{"type":20,"value":83},{"type":15,"tag":51,"props":1626,"children":1627},{"style":86},[1628],{"type":20,"value":1447},{"type":15,"tag":51,"props":1630,"children":1631},{"style":64},[1632],{"type":20,"value":83},{"type":15,"tag":51,"props":1634,"children":1635},{"style":64},[1636],{"type":20,"value":98},{"type":15,"tag":51,"props":1638,"children":1639},{"style":64},[1640],{"type":20,"value":1641}," '",{"type":15,"tag":51,"props":1643,"children":1644},{"style":86},[1645],{"type":20,"value":1488},{"type":15,"tag":51,"props":1647,"children":1648},{"style":64},[1649],{"type":20,"value":83},{"type":15,"tag":51,"props":1651,"children":1652},{"style":64},[1653],{"type":20,"value":189},{"type":15,"tag":51,"props":1655,"children":1656},{"class":53,"line":192},[1657],{"type":15,"tag":51,"props":1658,"children":1659},{"style":64},[1660],{"type":20,"value":198},{"type":15,"tag":1662,"props":1663,"children":1664},"style",{},[1665],{"type":20,"value":1666},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":7,"searchDepth":136,"depth":136,"links":1668},[1669,1670],{"id":24,"depth":136,"text":27},{"id":1325,"depth":136,"text":1328},"markdown","content:article:coding:resolve-error-from-phpunit-and-sqlite-by-refresh-database-in-laravel.md","content","article/coding/resolve-error-from-phpunit-and-sqlite-by-refresh-database-in-laravel.md","article/coding/resolve-error-from-phpunit-and-sqlite-by-refresh-database-in-laravel","md",1766375573987]