A
A
Artem00712018-10-27 15:38:30
Laravel
Artem0071, 2018-10-27 15:38:30

How to make a migration while testing?

I'm trying to make a small package
It needs migration
Created, placed in src / migrations
In the PackageServiceProvider in the register method I wrote:

$this->loadMigrationsFrom(__DIR__ . '/migrations/2018_10_10_000000_create_tables.php');

// вот это работает (просто чтобы не подумали что вообще ничего не работает)
$this->mergeConfigFrom(
            __DIR__ . '/config/account.php', 'account'
        );

I created a test in tests/unit, using RefreshDatabase
As a result, the configs that I connected work, but the tables from the migration are not created
How can this be fixed?
PS. In the test I wrote:
dd(DB::select("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"));

As a result, there are all tables except those that I added.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem0071, 2018-10-27
@Artem0071

Something tupanul and for some reason wrote a migration, you just had to specify the folder ..

M
Max Kostinevich, 2018-10-27
@max-ko

Try moving the migrations to the boot method as written in the documentation: https://laravel.com/docs/5.7/packages#migrations

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question