Skip to content

SQLite: Foreign keys are not enforcedΒ #36

@masdaster

Description

@masdaster

When querying 'PRAGMA foreign_keys' the result is 0 or 'OFF'. I tried to create a config file for the database like it's working with Laravel but the settings are only applied partially.

File: config/database.php

<?php

return [
    'default' => 'sqlite',
    'connections' => [
        'sqlite' => [
            'driver'                  => 'sqlite',
            'database'                => _env('DB_DATABASE', 'test.sqlite'),
            'prefix'                  => '',
            'foreign_key_constraints' => _env('DB_FOREIGN_KEYS', true),
            'journal_mode'            => 'WAL',
            'synchronous'             => 'OFF',
        ],
    ]
];

I've got some issues with journal mode defaulting to "DELETE". This caused my API to freeze because Auth is using the DB too. So I tried to apply WAL mode and it's working as intended. Unfortunately the settings "synchronous" and "foreign_key_constraints" are not applied.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions