İlk temizlik tamamlandı bir önceki projeden
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class MigrateFromDate extends Command
|
||||
{
|
||||
protected $signature = 'migrate:from-date {date}';
|
||||
protected $description = 'Migrate migrations from a specific date';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$date = $this->argument('date');
|
||||
$migrationsPath = database_path('migrations');
|
||||
$migrations = File::files($migrationsPath);
|
||||
|
||||
foreach ($migrations as $migration) {
|
||||
$migrationDate = substr($migration->getFilename(), 0, 10); // YYYY_MM_DD kısmını alır
|
||||
|
||||
if ($migrationDate > $date) {
|
||||
Artisan::call('migrate', ['--path' => 'database/migrations/' . $migration->getFilename()]);
|
||||
$this->info('Migrated: ' . $migration->getFilename());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user