Easy way, package?, for patching migrations?

Posted 3 years ago by whitneykrape

Hi, Is there an easy way to do updates to existing tables? Something that would be run when a table change is going to be made then keep track of if the patch been applied (for multi-environment management in particular.) Example of the current, clunky, method below. (Posted on Laravel.io as well but that forum has a ton of spam.)

    if (!Schema::hasTable('example_table')) :
    Schema::create('example_table', function(Blueprint $table)
    {
        $table->increments('id');
        $table->string('text');
    });
    else :
    /* PATCH 06 12 2016 - PATCHED 06 12 2016 */
    Schema::table('example_table', function ($table) {
        $table->string('new_text')->after('text');
        $table->dropColumn('text');
    });
    endif;

Please sign in or create an account to participate in this conversation.