![Theme Switcher Image](https://stackcoder.in/images/theme-switcher.png?cb=stackcoder90070)
Good content takes time and effort to come up with.
Please consider supporting us by just disabling your AD BLOCKER and reloading this page again.
Many times when you are working on SQLite database with Laravel you might have come across a wired error that SQLite doesn't support dropping foreign keys.
The reason is SQLite database has no concept called foreign keys. Let's fix this issue in Laravel.
To fix the DBAL issues make sure to install the following package.
composer require doctrine/dbal
Example 1
public function down()
{
Schema::table('comments', function (Blueprint $table) {
$table->dropForeign(['parent_id']);
$table->dropColumn(['parent_id']);
});
}
Example 1
public function down()
{
Schema::table('comments', function (Blueprint $table) {
/** Make sure to put this condition to check if driver is SQLite */
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign(['parent_id']);
}
$table->dropColumn(['parent_id']);
});
}
You can put this condition for multiple columns too.
Example 2
public function down()
{
Schema::table('payments', function (Blueprint $table) {
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign(['coupon_id']);
$table->dropForeign(['currency_id']);
}
$table->dropColumn(['status', 'currency_id', 'coupon_id', 'notes', 'invoice_number']);
});
}
I hope this might have solved your issues. Happy coding.
URL Redirects From Called Functions In Laravel
composer.json v/s composer.lock
PHP Built-In Web Server & Testing Your Development Project In Mobile Without Any Software
Foreign Key Migrations Simplified In Laravel 7.x
Generate Fake Data In PHP With Faker
Make Laravel Controllers Slim By Skimming Form Validation Request
Relationship Table Data With Route Model Binding In Laravel
Comment And Like System Using Disqus
Add Google ADS In AMP (Accelerated Mobile Pages) Website
Google reCAPTCHA Integration In PHP Laravel Forms
Accessors And Mutators In PHP Laravel
Create / Save / Download PDF From Blade Template In PHP Laravel