mercredi 7 juin 2017

artisan migration and seeding on sqlite in memory, always empty?

I'm trying to setup migration and seeding for a Laravel 5.4 application. Migration and seeding are working for mysql db. However when I try to run it on a sqlite in memory db, it seems to me that the db remains empty. Migration apparently run, but seeding complains about missing tables.

I simply configured sqlite as this in database.php

    'sqlite_memory' => [
        'driver' => 'sqlite',
        'database' => ':memory:',
        'prefix' => '',
    ],

and I set my default connections as

'default' => env('DB_CONNECTION', 'test_sqlite'),

I had eliminated all other kinds of connections from database.php and .env, just in case.

After succesfully running php artisan migrate, I enter sqlite3 and I see only a db:

Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .database
seq  name             file                                                      
---  ---------------     
 0    main                                                                       
sqlite> .dbinfo
sqlite> .tables
sqlite> 

It looks to me as there is nothing inside. If I try php artisan db:seed, I get immediately "no such table error" on any table..

I did manage however to make sqlite work with file db. I don't know how to troubleshoot this...



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire