first commit
This commit is contained in:
55
database/factories/MigrationScheduleFactory.php
Normal file
55
database/factories/MigrationScheduleFactory.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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 * * * *',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user