CodeIgniter Forums
What is the proper way to abort a migration? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: What is the proper way to abort a migration? (/showthread.php?tid=86858)



What is the proper way to abort a migration? - objecttothis - 02-21-2023

CI 4.3.1

If, in the up() function of a migration I have some check that causes me to want to abort the migration so that the migration does not continue and does not get added to the migrations table in the database, how would I do this?

PHP Code:
public function up(): void
{
    if(
$foo !== $bar)
    {
        
//abort the migration
    
}


I would like to be able to send the error back to the Login controller so that the view can gracefully display that the migration failed.


RE: What is the proper way to abort a migration? - InsiteFX - 02-21-2023

The only thing I see in the documentation is the regress command that allows going back.

Database Migration -> Class Reference -> regress

I did not see any type of abort commands.