Support foreign keys with SQLite (#590)
This commit is contained in:
@@ -29,13 +29,13 @@ chmod -R g+rw var/
|
||||
cp .env.dist .env
|
||||
```
|
||||
|
||||
It's up to you which database server you want to use, Kimai v2 supports MySQL/MariaDB and SQLite, but SQLite is [not recommended](faq.md) for production usage.
|
||||
Configure the database connection string in your the `.env` file:
|
||||
Configure the database connection string in your the `.env` file (Kimai v2 supports MySQL/MariaDB and SQLite):
|
||||
```
|
||||
# adjust all settings in .env to your needs
|
||||
APP_ENV=prod
|
||||
DATABASE_URL=mysql://user:password@127.0.0.1:3306/database
|
||||
```
|
||||
SQLite is not recommended for production usage, check FAQ below.
|
||||
|
||||
Now install all dependencies for Kimai 2:
|
||||
```bash
|
||||
@@ -209,6 +209,16 @@ npm run prod
|
||||
|
||||
## FAQ and common problems
|
||||
|
||||
## SQLite not recommended for production usage
|
||||
|
||||
SQLite is a great database engine for testing, but when it comes to production usage it is imperfect due to several reasons:
|
||||
|
||||
- It does not support ALTER TABLE commands and makes update procedures very clunky and problematic (we still try to support updates, but they are heavy on large databases)
|
||||
- It does [not support FOREIGN KEY](https://www.sqlite.org/quirks.html#foreign_key_enforcement_is_off_by_default) constraints [out of the box](https://www.sqlite.org/foreignkeys.html#fk_enable), which can lead to critical bugs when deleting users/activities/projects/customers
|
||||
|
||||
Kimai works around the Foreign Keys issue by using a [Doctrine PostConnect EventSubscriber]({{ site.kimai_v2_file }}/src/Doctrine/SqliteSessionInitSubscriber.php) since v0.8.1,
|
||||
but it is not guaranteed that SQLite handles everything as expected.
|
||||
|
||||
### Malformed parameter "url"
|
||||
|
||||
If you see an error message like this, then you have a special character in your DATABASE_URL.
|
||||
|
||||
Reference in New Issue
Block a user