Skip to content

Conversation

PsyLogic
Copy link

@PsyLogic PsyLogic commented May 10, 2020

Sometimes we are dealing with an existing projects and we decide to add Unit Testing,
the issue is when we have a hundreds of migrations some of them are dropping columns and adding new columns to an existing tables also dropping foreign keys it become hard to maintain since we always prefer to use SQLite on memory or local file
The solution that provided is adding more test inside the migrations files like:

if (\DB::getDriverName() != 'sqlite') {
  $table->string('column');
}else{
  $table->string('column')->nullable();
}

or

if (\DB::getDriverName() != 'sqlite') {
   $table->dropColumn('column1');
   $table->dropColumn('column2');
}else{
   $table->dropColumn(['column1', 'column2']);
}

Or Create separate migrations or modify all the affected migrations by refactoring code to suit SQLite limitations.

It would be great to cover all SQLite limitation in new versions

@GrahamCampbell GrahamCampbell changed the title Enhance most of known SQLite issues when dealing with PHP-Unit [6.x] Enhance most of known SQLite issues when dealing with PHP-Unit May 10, 2020
@GrahamCampbell GrahamCampbell changed the title [6.x] Enhance most of known SQLite issues when dealing with PHP-Unit [6.x] Enhance most of known SQLite issues when dealing with PHPUnit May 10, 2020
@GrahamCampbell GrahamCampbell changed the title [6.x] Enhance most of known SQLite issues when dealing with PHPUnit [6.x] Work around SQLite issue with columns May 10, 2020
@koenhoeijmakers
Copy link
Contributor

Genuinely curious: what makes it so that you prefer using a database driver that doesn't reflect your production environment while testing?

@PsyLogic
Copy link
Author

PsyLogic commented May 10, 2020

Genuinely curious: what makes it so that you prefer using a database driver that doesn't reflect your production environment while testing?

You are right is not gonna reflect my production, but
First I hate to see red errors on the console while testing
Second I hate to fix this red errors by adding conditions on existing migrations files.

I could solve this only on my ENV by add custom connection::resolverFor sqlite and register it in the service provider.

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions!

If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants