Files
project-replica/database/factories/MigrationScheduleFactory.php
2026-03-23 00:51:38 +09:00

56 lines
1.5 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\MigrationSchedule;
use App\Models\SourceDatabase;
use App\Models\TargetDatabase;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\MigrationSchedule>
*/
class MigrationScheduleFactory extends Factory
{
protected $model = MigrationSchedule::class;
public function definition(): array
{
return [
'name' => fake()->unique()->sentence(3),
'source_database_id' => SourceDatabase::factory(),
'target_database_id' => TargetDatabase::factory(),
'tables' => [1, 2, 3],
'cron_expression' => fake()->randomElement(['0 * * * *', '0 0 * * *', '0 0 * * 0']),
'timezone' => 'UTC',
'is_active' => true,
'run_in_parallel' => false,
'batch_size' => 1000,
'truncate_before_migration' => false,
'create_indexes_after' => true,
'description' => fake()->optional()->sentence(),
];
}
public function inactive(): static
{
return $this->state(fn (array $attributes) => [
'is_active' => false,
]);
}
public function daily(): static
{
return $this->state(fn (array $attributes) => [
'cron_expression' => '0 0 * * *',
]);
}
public function hourly(): static
{
return $this->state(fn (array $attributes) => [
'cron_expression' => '0 * * * *',
]);
}
}