Skip to content

Commit

Permalink
document sqlite foreign key setting
Browse files Browse the repository at this point in the history
  • Loading branch information
dakira committed Oct 30, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 654c530 commit e6b24ea
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions database.md
Original file line number Diff line number Diff line change
@@ -34,6 +34,15 @@ After creating a new SQLite database using a command such as `touch database/dat
DB_CONNECTION=sqlite
DB_DATABASE=/absolute/path/to/database.sqlite

To enable foreign key constraints for your SQLite connections, you can add the `foreign_key_constraints` option to `config/database.php` like this:

'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => true,
],

<a name="read-and-write-connections"></a>
### Read & Write Connections

4 changes: 2 additions & 2 deletions migrations.md
Original file line number Diff line number Diff line change
@@ -454,7 +454,7 @@ You may also specify the desired action for the "on delete" and "on update" prop
->references('id')->on('users')
->onDelete('cascade');

To drop a foreign key, you may use the `dropForeign` method. Foreign key constraints use the same naming convention as indexes. So, we will concatenate the table name and the columns in the constraint then suffix the name with "_foreign":
To drop a foreign key, you may use the `dropForeign` method. Foreign key constraints use the same naming convention as indexes. So, we will concatenate the table name and the columns in the constraint then suffix the name with "\_foreign":

$table->dropForeign('posts_user_id_foreign');

@@ -468,4 +468,4 @@ You may enable or disable foreign key constraints within your migrations by usin

Schema::disableForeignKeyConstraints();

> {note} SQLite disables foreign key constraints by default. When using SQLite, make sure to enable foreign key support before attempting to create them in your migrations.
> {note} SQLite disables foreign key constraints by default. When using SQLite, make sure to [enable foreign key support](/docs/{{version}}/database#configuration) in your database configuration before attempting to create them in your migrations.

0 comments on commit e6b24ea

Please sign in to comment.