I'm trying to set up some unit tests in a legacy Laravel project. This project has a lot of migration scripts creating and updating the database. This migrations work fine on a MySQL database, however I don't want to persist a test database so I'm using the standard .env.testing configuration of a Sqlite database:
One of the migration files contains the following:
public function up()
{
Schema::table('product_variants', function (Blueprint $table) {
$table->dropColumn(['sku']);
});
}
While this migration works in MySQL, when I try to run the migration in test mode (i.e. in Sqlite) I get the following message:
Reading the Laravel Docs, it's not supported to remove multiple columns from a Sqlite connection, so I converted the array param to a string (['sku']
into 'sku'
) but that did not change anything.
How do I get the migration to work in Sqlite?
Edit
Following the comment by BkiD (the column is indexed), I have attempted to identify what the index name of the column is using the following code:
$sm = Schema::getConnection()->getDoctrineSchemaManager();
$indexesFound = $sm->listTableIndexes('product_variants');
var_dump($indexesFound);die;
I was expecting an array of generated names, specifically I was expecting to see product_variants_sku_unique
. What I actually got was an empty array: array(0){}
Edit2
Tried manually dropping the index anyway:
Schema::table('product_variants', function (Blueprint $table) {
$table->dropUnique('product_variants_sku_unique');
});
Any other name throws a message that the index does not exist. Since this is not throwing an error, I assume the index exists, even if the previous code does not return it. So. I'm "dropping" the index then trying to drop the sku column, but still getting the same message.