Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why is laravel 5 artisan migrate not creating sqlite database?

I'm trying to use artisan migrate to create tables in sqlite.

I have the following in database.php

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

and this is my migrate class up function

    Schema::connection('sqlite')->create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();
    });

Note:- I have set DB_CONNECTION to be sqlite via the environment variable.

On the command line I get nothing to migrate, and no db is created (also no table).

Any ideas how I can get artisan migrate to create an sqlite db in laravel 5?

I have no problem creating mysql tables via artisan.

Thanks

like image 345
lucsan Avatar asked Jan 05 '23 19:01

lucsan


1 Answers

its because you didnt create the db. use touch command like this to create new sqlite database.

touch database/database.sqlite

then configure the environment variable like this

DB_CONNECTION=sqlite
DB_DATABASE=/absolute/path/to/database.sqlite
like image 186
Al Ameen Avatar answered Jan 21 '23 16:01

Al Ameen