Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

philb's avatar
Level 15

sqlite database is empty after migrate

I'm following along with Laravel 5 Fundamentals (migrations) and am struggling to get the migration to work.

  • I have set up database.sqlite in project/database.
  • I run 'php artisan migrate' which appears to successfully migrate tables
  • But, when I check project/database/database.sqlite it is empty (tested by running sqlite3 and also viewing the file)

I've checked the video comments, countless threads and googled a lot but cannot find a solution that works for me. I'm sure it's something simple that I'm missing.

From config/database.php

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

    'connections' => [

     'sqlite' => [
            'driver' => 'sqlite',
            'database' => database_path('database.sqlite'),
            'prefix' => '',
        ],

From .env (not sure whether I need to change this config)

DB_DATABASE='database/database.sqlite'
DB_DRIVER=sqlite

I'm running this through homestead ssh. Any help would be greatly appreciated.

1 like
5 replies
Snapey's avatar

out of the box is 'database' => storage_path('database.sqlite'), ... there is no database_path unless you have created it

Also, it should be in a place that is writeable, ie, the storage folder

Finally, your .env is not being used at all since you don't defer to values from there in your config file.

1 like
philb's avatar
Level 15

Thanks. I've created a new database.sqlite in storage and updated database.php, but the database is still empty. This is after rolling back the migration and then migrating again.

Do I need to define 'storage_path' anywhere, or is that already defined? (sorry, I'm new to Laravel!)

I've tried (from Jeffrey's video)

     'sqlite' => [
            'driver' => 'sqlite',
            'database' => storage_path().'database.sqlite',
            'prefix' => '',
        ],

and

'sqlite' => [
            'driver' => 'sqlite',
            'database' => storage_path('database.sqlite'),
            'prefix' => '',
        ],
1 like
aardalich's avatar

Out of the box these days it is

        'sqlite' => [
            'driver' => 'sqlite',
            'database' => env('DB_DATABASE', database_path('database.sqlite')),
            'prefix' => '',
        ],

and do

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

and make sure to initialise a file in the shell

touch database/database.sqlite

not sure if you have to make sure it's world writable which you'd do by issuing the command

chmod 777 database/database.sqlite

and when migrating, make sure you're doing it within wherever you environment is. Within your vagrant VM for example if you're running your environment within there

1 like
philb's avatar
Level 15

That didn't work either unfortunately. I'm migrating inside the vagrant VM. I wonder if there's something wrong with the way I set up homestead? I might start from scratch and see.

1 like
NilaWaEbabie's avatar

This post is over a year old but I just came across the same situation Philb was. Well the solution (which at least worked for me) is to edit conf/database.php as follows; 'default' => env('DB_CONNECTION', 'sqlite'), to 'default' => 'sqlite', and then remove any databse connection code blocks in your .env file.

1 like

Please or to participate in this conversation.