Skip to content

A self-hosted media server and file management system

feat: server config seeder

aminnausin720bd211d6b4
diff --git a/app/Models/ServerConfig.php b/app/Models/ServerConfig.php
index 473edc4a..19731dcf 100644
--- a/app/Models/ServerConfig.php
+++ b/app/Models/ServerConfig.php
@@ -15,11 +15,12 @@ class ServerConfig extends Model {
* created_at -> timestamptz (nullable)
* updated_at -> timestamptz (nullable)
*/
-
protected $fillable = [
'value',
'default_value',
'type',
- 'group'
+ 'group',
+ 'created_at',
+ 'updated_at',
];
}
diff --git a/config/media.php b/config/media.php
index 1e585914..49a65047 100644
--- a/config/media.php
+++ b/config/media.php
@@ -7,4 +7,13 @@ return [
'storage' => [
'prefix' => 'storage/media/',
],
+ 'format_map' => [
+ 'mp4' => 'mp4',
+ 'm4a' => 'mp4',
+ 'mkv' => 'matroska',
+ 'mp3' => 'mp3',
+ 'ogg' => 'opus',
+ 'opus' => 'opus',
+ 'flac' => 'flac',
+ ],
];
diff --git a/database/migrations/2026_05_04_040812_create_server_config_table.php b/database/migrations/2026_05_04_040812_create_server_config_table.php
index a0bc8fb7..9a0fbfa1 100644
--- a/database/migrations/2026_05_04_040812_create_server_config_table.php
+++ b/database/migrations/2026_05_04_040812_create_server_config_table.php
@@ -2,6 +2,7 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
@@ -9,20 +10,24 @@ return new class extends Migration {
* Run the migrations.
*/
public function up(): void {
- Schema::create('server_config', function (Blueprint $table) {
- $table->string("key")->primary();
+ Schema::create('server_configs', function (Blueprint $table) {
+ $table->string('key')->primary();
$table->text('value');
$table->text('default_value');
- $table->enum("type", ['string', 'boolean', 'integer', 'array', 'float']);
+ $table->enum('type', ['string', 'boolean', 'integer', 'array', 'float']);
$table->enum('group', ['scanning', 'metadata', 'media', 'performance', 'storage'])->index();
$table->timestampsTz();
});
+
+ Artisan::call('db:seed', [
+ '--class' => 'ServerConfigSeeder',
+ ]);
}
/**
* Reverse the migrations.
*/
public function down(): void {
- Schema::dropIfExists('server_config');
+ Schema::dropIfExists('server_configs');
}
};
diff --git a/database/seeders/ServerConfigSeeder.php b/database/seeders/ServerConfigSeeder.php
new file mode 100644
index 00000000..1fc18276
--- /dev/null
+++ b/database/seeders/ServerConfigSeeder.php
@@ -0,0 +1,99 @@
+<?php
+
+namespace Database\Seeders;
+
+use Illuminate\Database\Seeder;
+use Illuminate\Support\Facades\DB;
+
+class ServerConfigSeeder extends Seeder {
+ /**
+ * Run the database seeds.
+ */
+ public function run(): void {
+ $configs = [
+ [
+ 'key' => 'media_formats',
+ 'value' => json_encode(config('media.format_map')),
+ 'default_value' => json_encode(config('media.format_map')),
+ 'type' => 'array',
+ 'group' => 'media',
+ ],
+ [
+ 'key' => 'max_scan_workers',
+ 'value' => 10,
+ 'default_value' => 10,
+ 'type' => 'integer',
+ 'group' => 'performance',
+ ],
+ [
+ 'key' => 'max_event_workers',
+ 'value' => 5,
+ 'default_value' => 5,
+ 'type' => 'integer',
+ 'group' => 'performance',
+ ],
+ [
+ 'key' => 'uuid_embed',
+ 'value' => true,
+ 'default_value' => true,
+ 'type' => 'boolean',
+ 'group' => 'scanning',
+ ],
+ [
+ 'key' => 'uuid_write_cache',
+ 'value' => false,
+ 'default_value' => false,
+ 'type' => 'boolean',
+ 'group' => 'scanning',
+ ],
+ [
+ 'key' => 'attachments_extract',
+ 'value' => false,
+ 'default_value' => false,
+ 'type' => 'boolean',
+ 'group' => 'scanning',
+ ],
+ [
+ 'key' => 'art_extract',
+ 'value' => true,
+ 'default_value' => true,
+ 'type' => 'boolean',
+ 'group' => 'scanning',
+ ],
+ [
+ 'key' => 'thumbnails_generate',
+ 'value' => false,
+ 'default_value' => false,
+ 'type' => 'boolean',
+ 'group' => 'scanning',
+ ],
+ [
+ 'key' => 'thumbnails_auto_download',
+ 'value' => true,
+ 'default_value' => true,
+ 'type' => 'boolean',
+ 'group' => 'scanning',
+ ],
+ [
+ 'key' => 'cache_path',
+ 'value' => 'cache',
+ 'default_value' => 'cache',
+ 'type' => 'string',
+ 'group' => 'storage',
+ ],
+ [
+ 'key' => 'metadata_path',
+ 'value' => 'metadata',
+ 'default_value' => 'metadata',
+ 'type' => 'string',
+ 'group' => 'storage',
+ ],
+ ];
+
+ foreach ($configs as &$config) {
+ $config['created_at'] = $config['updated_at'] = now();
+ }
+
+ DB::table('server_configs')->insertOrIgnore($configs);
+ }
+}