[12.X] Add connection information in the migration output.#56791
[12.X] Add connection information in the migration output.#56791kachelle wants to merge 5 commits intolaravel:12.xfrom
Conversation
|
Test needs to be updated. |
|
@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. |
|
@crynobone @kachelle if you want I can take a look to try to work on the tests for this |
|
Thanks @WendellAdriel , if needed contact me (twitter), I'm happy to assist/learn. |
|
@kachelle Update the file: 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. |
|
Thanks @WendellAdriel , I don't have time this week to work on this. Next week I look into this! |
@WendellAdriel maybe you can send a PR against their feature branch? |
|
Thanks @WendellAdriel ! I did your changes step by step! ❤️ |
|
Do we want the driver name? I feel like the connection name would be more appropriate, or maybe even both. Maybe something like granted, for a lot of people these would end up being the same word, so maybe just the connection name is more appropriate. |
|
Or something more like this: $databaseDriverMap = [
'sqlite' => ['label' => 'SQLite', 'color' => '#044a64'],
'mysql' => ['label' => 'MySQL', 'color' => '#3E6E93'],
'mariadb' => ['label' => 'MariaDB', 'color' => '#4e629a'],
'pgsql' => ['label' => 'PosgreSQL', 'color' => '#336791'],
'sqlsrv' => ['label' => 'MS SQL Server', 'color' => '#1b9fe7'],
];
$driver = $this->migrator->resolveConnection($this->option('database'))->getDriverName();
['label' => $label, 'color' => $color] = $databaseDriverMap[$driver] ?? ['label' => $driver, 'color' => 'grey'];
$this->output->writeln(sprintf('<fg=white;bg=%s>%s</> Preparing %s database', $color, $label, $this->option('database')); |
|
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 applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions! |
Output before:
After this pr:
Reason:
Lost some time because my migrations were successfull on Cloud, but no data was in my remote database.
Because they ran on a
sqlitedb. Because the default value forDB_CONNECTIONis set to that.My first PR, please let me know if things should be done differently.