Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document sqlite foreign key setting #4702

Merged
merged 1 commit into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions database.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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.