Skip to content

Latest commit

 

History

History
22 lines (20 loc) · 612 Bytes

avoid-no-such-column-errors-when-dropping-multiple-columns-in-sqlite.md

File metadata and controls

22 lines (20 loc) · 612 Bytes

Avoid "no such column" error when dropping multiple columns in sqlite

If we are dropping multiple tables from the database in sqlite (usually when running migrate:refresh), instead if this:

Schema::table('products', function (Blueprint $table) {
    # This can cause "no such column" errors in SQLite
    $table->dropColumn('sku');
    $table->dropColumn('base_price');
    $table->dropColumn('description');
});

We should do this:

Schema::table('products', function (Blueprint $table) {
    $table->dropColumn([
        'sku',
        'base_price',
        'description'
    ]);
});