The following schema builder code works perfectly when running php artisan migrate
and php artisan migrate:rollback
on local and staging (production-like) environment. This will run an alter table
statement to modify an existing table.
Note: since rows are empty, there is no need to set nullable
or default value
to the category_id
:
// up
$table->integer('category_id')->unsigned()->index();
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
// down
$table->dropForeign('stores_category_id_foreign');
$table->dropColumn('category_id');
I'm running my functional tests with SQLite using :memory:
configuration, and I'm getting the following error when the database rolls back (thanks to the DatabaseMigrations
trait)
General error: 1 no such index: stores_category_id_index (SQL: DROP INDEX stores_category_id_index)
Why is this happening, is there something I have to configure on SQLite that I don't know of?
How to change data type of column in laravel 9 migration ? Step 1 : Install doctrine/dbal package. Step 2 : Generate migration file. Step 3 : Open generated migration file and update.
16) When can you get an SQLITE_SCHEMA error? The SQLITE_SCHEMA error is returned when a prepared SQL statement is not valid and cannot be executed. Such type occurs only when using the sqlite3 prepare() and sqlite3 step() interfaces to run SQL.
Actually, SQLite will easily do 50,000 or more INSERT statements per second on an average desktop computer. But it will only do a few dozen transactions per second.
By default SQLite has foreign key support disabled.
You'll need to enabled it manually or use a different DB.
Laravel 5.1: Enable SQLite foreign key constraints
Link above talks about how to do this but essentially you need to find a way to run 'PRAGMA foreign_keys=1' on your functional test environment before tests.
Disclaimer: I've only tried this on Laravel 5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With