Skip to content

Conversation

kachelle
Copy link

Output before:

   INFO  Preparing database.  

  Creating migration table ....................................... 5.60ms DONE 

After this pr:

   INFO  Preparing sqlite database.

  Creating migration table ....................................... 5.60ms DONE 

Reason:
Lost some time because my migrations were successfull on Cloud, but no data was in my remote database.
Because they ran on a sqlite db. Because the default value for DB_CONNECTION is set to that.

My first PR, please let me know if things should be done differently.

@kachelle kachelle marked this pull request as draft August 27, 2025 13:44
@crynobone
Copy link
Member

Test needs to be updated.

@crynobone crynobone added the needs work Not quite ready for primetime label Sep 11, 2025
@kachelle
Copy link
Author

@crynobone yes I know. But my knowledge of working on framework is very limited. I have a lot of experience with the framework. If you want we can hop on a call to work on this PR? DM me on twitter

If not, this PR can be deleted.

@WendellAdriel
Copy link
Contributor

@crynobone @kachelle if you want I can take a look to try to work on the tests for this

@kachelle
Copy link
Author

Thanks @WendellAdriel , if needed contact me (twitter), I'm happy to assist/learn.

{
if (! $this->repositoryExists()) {
$this->components->info('Preparing database.');
$this->components->info('Preparing '.$this->migrator->resolveConnection($this->option('database'))->getDriverName().' database.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->components->info('Preparing '.$this->migrator->resolveConnection($this->option('database'))->getDriverName().' database.');
$this->components->info(sprintf(
'Preparing %s database.',
$this->migrator->resolveConnection($this->option('database'))->getDriverName()
));

@WendellAdriel
Copy link
Contributor

@kachelle
For the tests.

Update the file: tests/Database/DatabaseMigrationMigrateCommandTest.php
Update the method: testMigrationRepositoryCreatedWhenNecessary to this:

Below the first line of this method:

$params = [$migrator = m::mock(Migrator::class), $dispatcher = m::mock(Dispatcher::class)];

Add these two lines:

$connectionMock = m::mock(Connection::class);
$connectionMock->shouldReceive('getDriverName')->andReturn('sqlite');

Then below this line:

$migrator->shouldReceive('hasRunAnyMigrations')->andReturn(true);

Add this line:

$migrator->shouldReceive('resolveConnection')->andReturn($connectionMock);

This should fix the test.
This is needed because with your change, the test was not mocking the call to the resolveConnection method.

@kachelle
Copy link
Author

Thanks @WendellAdriel , I don't have time this week to work on this. Next week I look into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs work Not quite ready for primetime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants