Railalis's avatar

Sqlite Migration Error - Unable to open database file

I have been developing an app on a machine I have at home. I pushed the project to github and am attempting to migrate the database on a new machine. Both machines are using Homestead on windows as the host. Everything on the home machine works.

On the problematic machine ssh'ed into homestead:

06:44:32 {master} ~/Code/InnKeep$ php artisan migrate --seed
Migration table created successfully.

  [Illuminate\Database\QueryException]
  SQLSTATE[HY000]: General error: 14 unable to open database file (SQL: insert into "migrations" ("migration", "batch") values (2016_02_23_024642_create_books_table, 1))

  [PDOException]
  SQLSTATE[HY000]: General error: 14 unable to open database file

06:44:39 {master} ~/Code/InnKeep$ ls -l | grep database
drwxrwxrwx 1 vagrant vagrant   4096 Mar  2 18:44 database
06:44:52 {master} ~/Code/InnKeep$ ls -l database/
total 23
-rwxrwxrwx 1 vagrant vagrant 15360 Mar  2 18:44 database.sqlite
drwxrwxrwx 1 vagrant vagrant     0 Mar  1 16:26 factories
drwxrwxrwx 1 vagrant vagrant  4096 Mar  1 16:26 migrations
drwxrwxrwx 1 vagrant vagrant  4096 Mar  1 16:26 seeds

I've done some research and the consensus is that its a permission issue. Typically, the database folder doesn't have writeable permissions. That is not the case here.

Oddly, tables are still being created within the database.sqlite file and even some migration rows are being added. I have no idea what is going on. Any help?

0 likes
5 replies
thefuzzy0ne's avatar

Have you truncated the database file to confirm that these aren't just old tables you're looking at?

Also, please ensure that you have the correct SQLite database filename in your configuration.

If everything is done correctly, as you suspect, I reckon you might have something somewhere that's keeping a write lock on the file in question.

Railalis's avatar

Fresh database.sqlite file. Same Permissions, correct file name (since its adding tables)..

What might cause it to lock? Again, I have everything running just fine on a different machine with the same code. I can only assume its a homestead environment issue.

thefuzzy0ne's avatar

You could be right. Is your app runnable via php artisan serve (with Homstead shutdown/suspended)? If so, does it make any difference?

nojaf's avatar

I'm having the same error. I'm using LaraDock on Windows 10. Created empty database.sqlite file and tried to run php artisan migrate. Did you ever resolve this?

mdecooman's avatar

Hi,

Not used with windows for some time but is it ok to have vagrant the UID and GID of the file? What version of VirtualBox are you using ?

Can you run the command outside of the vagrant box from a command line in PowerShell? Assuming you have a version of PHP installed there (with a Wamp or else and tweaking the path variable to find it)

Please or to participate in this conversation.