DEV Community

Discussion on: Can you help me identify why I cannot run migrations in testing?

Collapse
 
hakobyansen profile image
Senik Hakobyan

Try to specify your pre-existing schema in the phpunit.xml config file.

<php>
         ...
        <env name="DB_DATABASE" value="your-schema-name" />
</php>

Make sure you have backup of that db before running the test. Laravel's DatabaseMigrations trait will drop everything and re-migrate.

Collapse
 
pcmagas profile image
Dimitrios Desyllas

I have tried that and I still get the error.

Collapse
 
hakobyansen profile image
Senik Hakobyan

Are you able to run that migration outside of the test?

Thread Thread
 
pcmagas profile image
Dimitrios Desyllas • Edited

By setting the test database, nope I am unable to run the migrations.

The cause is that the postgresql database I am using actually keeps the columns into the table even if I delete it from the table and just hides it from the user.

The solution is to reconstruct the test database. So how I can prepend my existing migrations with one that generates the database?