Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat: add seeder command and configuration for database seeding

Andras Bacsaid2ff8c652170
diff --git a/app/Console/Commands/Seeder.php b/app/Console/Commands/Seeder.php
new file mode 100644
index 0000000000..e37b6a9d27
--- /dev/null
+++ b/app/Console/Commands/Seeder.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+
+class Seeder extends Command
+{
+ protected $signature = 'start:seeder';
+
+ protected $description = 'Start Seeder';
+
+ public function handle()
+ {
+ if (config('constants.seeder.is_seeder_enabled')) {
+ $this->info('Seeder is enabled on this server.');
+ $this->call('db:seed', ['--class' => 'ProductionSeeder', '--force' => true]);
+ exit(0);
+ } else {
+ $this->info('Seeder is disabled on this server.');
+ exit(0);
+ }
+ }
+}
diff --git a/config/constants.php b/config/constants.php
index 3054df1f06..a02d6616aa 100644
--- a/config/constants.php
+++ b/config/constants.php
@@ -37,6 +37,10 @@ return [
'is_migration_enabled' => env('MIGRATION_ENABLED', true),
],
+ 'seeder' => [
+ 'is_seeder_enabled' => env('SEEDER_ENABLED', true),
+ ],
+
'horizon' => [
'is_horizon_enabled' => env('HORIZON_ENABLED', true),
'is_scheduler_enabled' => env('SCHEDULER_ENABLED', true),
diff --git a/docker/production/etc/s6-overlay/s6-rc.d/init-seeder/up b/docker/production/etc/s6-overlay/s6-rc.d/init-seeder/up
index 20d17c58b6..007f4233e5 100644
--- a/docker/production/etc/s6-overlay/s6-rc.d/init-seeder/up
+++ b/docker/production/etc/s6-overlay/s6-rc.d/init-seeder/up
@@ -6,10 +6,7 @@ cd /var/www/html
foreground {
php
artisan
- db:seed
- --class
- ProductionSeeder
- --force
+ start:seeder
}