feat: add migration to seed default application settings
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$settings = [
|
||||
'project_name' => 'Citrus CMS',
|
||||
'project_name_ru' => '',
|
||||
'project_number' => '',
|
||||
'company_code' => '',
|
||||
'row_count' => '20',
|
||||
'summary_mails' => '',
|
||||
'cron_job_batch_process_count' => '10',
|
||||
'cron_job_period' => '1',
|
||||
'gemini_api_key' => '',
|
||||
'header_color' => 'bg-primary-dark',
|
||||
'DevExpress_Theme' => 'dx.material.orange.light.compact.css',
|
||||
'pdf_template_path' => 'default',
|
||||
];
|
||||
|
||||
foreach ($settings as $key => $value) {
|
||||
// Check if setting already exists
|
||||
$exists = DB::table('settings')->where('title', $key)->exists();
|
||||
|
||||
if (!$exists) {
|
||||
DB::table('settings')->insert([
|
||||
'title' => $key,
|
||||
'html' => $value,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$keys = [
|
||||
'project_name',
|
||||
'project_name_ru',
|
||||
'project_number',
|
||||
'company_code',
|
||||
'row_count',
|
||||
'summary_mails',
|
||||
'cron_job_batch_process_count',
|
||||
'cron_job_period',
|
||||
'gemini_api_key',
|
||||
'header_color',
|
||||
'DevExpress_Theme',
|
||||
'pdf_template_path',
|
||||
'handover_control_count',
|
||||
];
|
||||
|
||||
DB::table('settings')->whereIn('title', $keys)->delete();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user