Skip to content

Commit bedb8c2

Browse files
authored
[11.x] Export cache, jobs, failed_jobs or sessions migration schema if the file doesn't exists based on new skeleton. (#49410)
* [11.x] Export `cache`, `jobs`, `failed_jobs` or `sessions` migration schema if the file doesn't exists based on new skeleton. Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> --------- Signed-off-by: Mior Muhammad Zaki <[email protected]>
1 parent 9cee0e6 commit bedb8c2

File tree

5 files changed

+63
-7
lines changed

5 files changed

+63
-7
lines changed

src/Illuminate/Queue/Console/FailedTableCommand.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,23 @@ protected function migrationStubFile()
4848
{
4949
return __DIR__.'/stubs/failed_jobs.stub';
5050
}
51+
52+
/**
53+
* Determine whether a migration for the table already exists.
54+
*
55+
* @param string $table
56+
* @return bool
57+
*/
58+
protected function migrationExists($table)
59+
{
60+
if ($table !== 'failed_jobs') {
61+
return parent::migrationExists($table);
62+
}
63+
64+
return count($this->files->glob(sprintf(
65+
'{%s,%s}',
66+
$this->laravel->joinPaths($this->laravel->databasePath('migrations'), '*_*_*_*_create_'.$table.'_table.php'),
67+
$this->laravel->joinPaths($this->laravel->databasePath('migrations'), '0001_01_01_000003_create_jobs_table.php'),
68+
))) !== 0;
69+
}
5170
}

src/Illuminate/Queue/Console/TableCommand.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,23 @@ protected function migrationStubFile()
4848
{
4949
return __DIR__.'/stubs/jobs.stub';
5050
}
51+
52+
/**
53+
* Determine whether a migration for the table already exists.
54+
*
55+
* @param string $table
56+
* @return bool
57+
*/
58+
protected function migrationExists($table)
59+
{
60+
if ($table !== 'jobs') {
61+
return parent::migrationExists($table);
62+
}
63+
64+
return count($this->files->glob(sprintf(
65+
'{%s,%s}',
66+
$this->laravel->joinPaths($this->laravel->databasePath('migrations'), '*_*_*_*_create_'.$table.'_table.php'),
67+
$this->laravel->joinPaths($this->laravel->databasePath('migrations'), '0001_01_01_000003_create_jobs_table.php'),
68+
))) !== 0;
69+
}
5170
}

src/Illuminate/Session/Console/SessionTableCommand.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,19 @@ protected function migrationStubFile()
4848
{
4949
return __DIR__.'/stubs/database.stub';
5050
}
51+
52+
/**
53+
* Determine whether a migration for the table already exists.
54+
*
55+
* @param string $table
56+
* @return bool
57+
*/
58+
protected function migrationExists($table)
59+
{
60+
return count($this->files->glob(sprintf(
61+
'{%s,%s}',
62+
$this->laravel->joinPaths($this->laravel->databasePath('migrations'), '*_*_*_*_create_'.$table.'_table.php'),
63+
$this->laravel->joinPaths($this->laravel->databasePath('migrations'), '0001_01_01_000000_create_users_table.php'),
64+
))) !== 0;
65+
}
5166
}

tests/Integration/Foundation/Console/AboutCommandTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
namespace Illuminate\Tests\Integration\Foundation\Console;
44

55
use Illuminate\Testing\Assert;
6+
use Orchestra\Testbench\Attributes\WithEnv;
67
use Orchestra\Testbench\TestCase;
78

89
use function Orchestra\Testbench\remote;
910

11+
#[WithEnv('APP_MAINTENANCE_STORE', 'array')]
1012
class AboutCommandTest extends TestCase
1113
{
1214
public function testItCanDisplayAboutCommandAsJson()
@@ -31,12 +33,12 @@ public function testItCanDisplayAboutCommandAsJson()
3133

3234
Assert::assertArraySubset([
3335
'broadcasting' => 'log',
34-
'cache' => 'file',
36+
'cache' => 'database',
3537
'database' => 'testing',
3638
'logs' => ['single'],
3739
'mail' => 'smtp',
3840
'queue' => 'database',
39-
'session' => 'file',
41+
'session' => 'database',
4042
], $output['drivers']);
4143
});
4244
}

tests/Integration/Foundation/MaintenanceModeTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,25 @@
1111
use Illuminate\Support\Carbon;
1212
use Illuminate\Support\Facades\Event;
1313
use Illuminate\Support\Facades\Route;
14+
use Orchestra\Testbench\Attributes\WithEnv;
1415
use Orchestra\Testbench\Http\Middleware\PreventRequestsDuringMaintenance as TestbenchPreventRequestsDuringMaintenance;
1516
use Orchestra\Testbench\TestCase;
1617
use Symfony\Component\HttpFoundation\Cookie;
1718

19+
#[WithEnv('APP_MAINTENANCE_DRIVER', 'file')]
1820
class MaintenanceModeTest extends TestCase
1921
{
2022
protected function setUp(): void
2123
{
24+
$this->beforeApplicationDestroyed(function () {
25+
@unlink(storage_path('framework/down'));
26+
});
27+
2228
parent::setUp();
2329

2430
$this->withoutMiddleware(TestbenchPreventRequestsDuringMaintenance::class);
2531
}
2632

27-
protected function tearDown(): void
28-
{
29-
@unlink(storage_path('framework/down'));
30-
}
31-
3233
public function testBasicMaintenanceModeResponse()
3334
{
3435
file_put_contents(storage_path('framework/down'), json_encode([

0 commit comments

Comments
 (0)