laravel ɾ³ýmigration
ÔÚlaravel¿ª·¢ÖУ¬ÎÒÃǾ³£»áʹÓÃmigrationÀ´ÖÎÀíÎÒÃǵÄÊý¾Ý¿â½á¹¹¡£¿ÉÊǵ±ÎÒÃÇÐèҪɾ³ýij¸ömigrationʱ£¬¸ÃÔõô°ìÄØ£¿
ÔÚÕâƪÎÄÕÂÖУ¬ÎÒÃǽ«ÌÖÂÛ¼¸ÖÖÒªÁìÀ´É¾³ýLaravelÖеÄmigration¡£
ÒªÁìÒ»£ºmigrate:rollback
LaravelÖÐÌṩÁËÒ»¸öºÜÊǼòÆÓµÄÒªÁìÍù·µ¹ömigration£¬Ê¹ÓÃÒÔÏÂÏÂÁ
php artisan migrate:rollback
µÇ¼ºó¸´ÖÆ
Õ⽫»Ø¹öÎÒÃÇ×îºóÒ»´ÎÖ´ÐеÄmigration¡£
¿ÉÊÇ£¬ÈôÊÇÎÒÃÇÏëҪɾ³ýÌض¨µÄmigration£¬¸ÃÔõô°ìÄØ£¿ÔÚÕâÖÖÇéÐÎÏ£¬ÎÒÃÇ¿ÉÒÔʵÑéʹÓÃÒÔÏÂÏÂÁ
php artisan migrate:rollback --step=1
µÇ¼ºó¸´ÖÆ
Õ⽫»Ø¹öÎÒÃÇ×îºóÒ»´ÎÖ´ÐеÄmigrationµÄ²½Êý¡£ÕâЩ°ì·¨¿ÉÒÔͨ¹ý–step=Ñ¡Ïî¾ÙÐиü¸Ä¡£ÀýÈ磬ÎÒÃÇÒª»Ø¹ö3¸ömigration£¬Ôò¿ÉÒÔÔËÐÐÒÔÏÂÏÂÁ
php artisan migrate:rollback --step=3
µÇ¼ºó¸´ÖÆ
ÐèҪעÖصÄÊÇ£¬»Ø¹ömigration»áɾ³ýÊý¾Ý¿âÖиÃmigration¶ÔÓ¦µÄÊý¾Ý±í£¬ÈôÊǸñíÖÐÓÐÊý¾Ý£¬ÔòÊý¾ÝÒ²»á±»É¾³ý¡£
ÒªÁì¶þ£ºmigration:rollback
ʹÓÃÒÔÏÂÏÂÁî¿ÉÒԻعömigration£º
php artisan migrate:rollback --path=/database/migrations/{specific_migration_file_name.php}
µÇ¼ºó¸´ÖÆ
ÔÚ»¨À¨ºÅÖУ¬Ê¹ÓÃÌض¨µÄmigrationÎļþÃûÀ´È¡´ú¡£Õ⽫»Ø¹öÖ¸¶¨µÄmigration²¢´ÓÊý¾Ý¿âÖÐɾ³ý¸Ãmigration¶ÔÓ¦µÄ±í¡£
ÐèҪעÖصÄÊÇ£¬»Ø¹ömigration»áɾ³ýÊý¾Ý¿âÖиÃmigration¶ÔÓ¦µÄÊý¾Ý±í£¬ÈôÊǸñíÖÐÓÐÊý¾Ý£¬ÔòÊý¾ÝÒ²»á±»É¾³ý¡£
ÒªÁìÈý£ºÉ¾³ýmigrationÎļþ²¢pass
ÎÒÃÇ¿ÉÒÔÖ±½Óɾ³ýmigrationÎļþ£¬µ«ÔÚ×öÕâ¸ö֮ǰ£¬ÎÒÃÇÐèÒªÔÚmigration±íÖн«¸ÃmigrationÎļþ¼Í¼ɾ³ý¡£²»È»£¬ÎÒÃǽ«ÎÞ·¨ÔÙ´ÎÔËÐÐmigrateÏÂÁî¡£
ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁmigrationÎļþ¼Í¼´Ómigration±íÖÐɾ³ý£º
php artisan migrate:reset
µÇ¼ºó¸´ÖÆ
Õ⽫´ÓÊý¾Ý¿âÖÐɾ³ýmigration±íÖеÄËùÓмͼ£¬ÒÔ±ãÎÒÃÇ¿ÉÒÔÖØÐÂÔËÐÐmigrateÏÂÁî¡£
ÏÖÔÚ£¬ÎÒÃÇ¿ÉÒÔɾ³ýÌض¨µÄmigrationÎļþ²¢pass¡£¿ÉÊÇ£¬ÎÒÃÇÐèҪעÖØÒÔϼ¸µã£º
ɾ³ýmigrationÎļþºó£¬ÎÒÃǽ«ÎÞ·¨»Ø¹ö¸Ãmigration¡£
ÈôÊǸÃmigrationÖÐÓÐÊý¾ÝǨá㣬ÔÚɾ³ýÎļþ֮ǰÎÒÃÇÐèÒªÏȽ¨×°±¸·Ý¡£
ËäÈ»£¬É¾³ýmigrationÎļþ²¢passÊÇ×î²»ÍƼöµÄÒªÁì¡£ÓÉÓÚÎÞ·¨»Ø¹öºÍÈÝÒ×·ºÆðÒì³£¡£
×ܽ᣺
ÕâЩҪÁ춼²»ÊÇÍêÉƵģ¬ËüÃÇ¿ÉÒÔƾ֤ÇéÐκÍÐèÇóÑ¡Ôñ¡£»ùÓÚѹËõ°üµÄÏîÄ¿£¬Ö»ÐèÒª²Ù×÷ɾ³ýij¸ömigrationÎļþ¼´¿É£»ÔÚÏßÇéÐÎÏ£¬ÐèÒª»Ø¹öÓëɾ³ýÖ¸¶¨migrationÖ®¼äµÄ²î±ð£¬ÕâÐèÒª¿ª·¢ÕßÔÚ²Ù×÷֮ǰ¶Ômigration±íÓÐÒ»¶¨µÄÏàʶ¡£ÔÚÈκÎÇéÐÎÏ£¬ÎÒÃǶ¼ÐèÒªÉóÉ÷²Ù×÷£¬¹ØÓÚɾ³ý²Ù×÷Ðè×öºÃÊý¾Ý±¸·Ý¡£
ÒÔÉϾÍÊÇlaravel ɾ³ýmigrationµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡