ddesyllas's avatar

Why by running migrate:refresh on test setUp phase fails to run the migration scripts

On a legacy projects we started to implement migration scripts upon a pre-existing database schema, so using the migration scripts we are able to update the schema BUT NOT to create the database schema from scratch because the migrations run upon a pre-existing schema existed prior even starting writing migrations for it.

The approach we use for testing is as follows:

namespace Tests\MyTest

use Illuminate\Foundation\Testing\TestCase as BaseTestCase;


class MyProjectTestCase extends BaseTestCase
{
    public function setUp()
    {
       Artisan::call('migrate:refresh',['--env'=>'testing']);
    }
}

And then on each TestCase we extend it like this:

class MyTests extends MyProjectTestCase
{

}

But Once I run my tests I get the following error:

2) Tests\MyTests::testSomething
Illuminate\Database\QueryException: SQLSTATE[54011]: Too many columns: 7 ERROR:  tables can have at most 1600 columns (SQL: alter table "my_table" add column "my_column" integer null, add column "delivery_services" boolean not null default '0', add column "delivery_services_new_age" boolean not null default '0')

The migration that causes it is the following:

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class MyMigration extends Migration
{
    public function up()
    {
        Schema::connection('my_connection')->table('my_table',function(Blueprint $table){
             if(!Schema::connection('etable_operations')->hasColumn('my_table','my_column')){
                  $table->mediumInteger('my_column')->unsigned()->nullable()->index();
             }
        });
    }

    public function down()
    {
        Schema::connection('etable_operations')->table('et_store_crm', function (Blueprint $table) {
             $table->dropColumn('my_column');
        });
    }
}

Do you have any idea why I get the error above?

0 likes
2 replies
EdgarIsmael's avatar

Some background: I work in a small startup of 8 people out of which 4 are devs ( 2 juniors including me, one senior, and CTO).

in my startup, we are currently using laravel blade files for displaying our application front-end. My goal is to move our front-end piece-by-piece to vue. ISO for the last 2-3 days I have been searching and looking for ways to build our app components and pages into vue. I have come across a few roadblocks and figured I'd ask y'all.

Here is where I currently am:

I have built 2 components (header, and a sidebar incomplete) and they are being rendered in my app.vue file. Keep in mind I am currently using vue router, we only have back-end routing that returned blade views.

My question is, https://showbox.bio/ https://tutuapp.uno/ https://vidmate.cool/ how do I avoid using vue-router, register, and use all my components in the vue pages?

As for the pages, how will I display them (do I create a blade file for each page and then render that page in the blade file?)

What are some architectural mishaps I can avoid?

Is there any project that roughly meets the requirements that I can mirror? I am willing to spend as long as it takes, but I want to get it right.

ddesyllas's avatar

Dear @edgarismael This is a seperate question and not answer to my problem. I would advise to ask it seperately if possible.

Please or to participate in this conversation.