adonisjs / lucid

AdonisJS SQL ORM. Supports PostgreSQL, MySQL, MSSQL, Redshift, SQLite and many more
https://lucid.adonisjs.com/
MIT License
1.03k stars 189 forks source link

sqlite: tmp folder is not created when run migration #895

Closed guoyunhe closed 1 year ago

guoyunhe commented 1 year ago

Package version

18.2.0

Node.js and npm version

Node 16.17.1 NPM 8.15.0

Reproduce Repo

git clone https://github.com/guoyunhe/adonis-sqlite-tmp-folder.git
cd adonis-sqlite-tmp-folder
cp .env.example .env
npm install
node ace migration:run

I got this error:

[ error ]  SQLITE_CANTOPEN: unable to open database file

The default sqlite file location is tmp/db.sqlite3. However, tmp folder is ignored by git. So when others clone the repo, it will not be created automatically.

Suggested solutions

A: change default sqlite file location to database folder

database folder is in version control. Laravel store its sqlite in this folder. I prefer this way because sqlite is main database and it is not a tmp file. tmp folder should only be used for tmp data, caching, or so.

B: add tmp folder into version control

Remove tmp from root .gitignore. Create tmp/.gitignore with:

*
!.gitignore
nandordudas commented 1 year ago

I think there is another possible option in suggested solutions. The tmp folder isn't creating properly.

This script works for me.

{
  "scripts": {
    "test": "mkdir -p tmp; node ace test"
  }
}
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.