migrate on appservice boot

This commit is contained in:
Andras Bacsai 2023-05-03 10:06:15 +02:00
parent 8bfdcdbf44
commit 1ad7d885b3
2 changed files with 5 additions and 11 deletions

View File

@ -10,7 +10,6 @@ class ForceUpgrade extends Component
{
public function upgrade()
{
//if (env('APP_ENV') === 'local') {
if (config('app.env') === 'local') {
$server = Server::where('ip', 'coolify-testing-host')->first();
if (!$server) {

View File

@ -7,6 +7,7 @@
use Illuminate\Support\Facades\Process;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
class AppServiceProvider extends ServiceProvider
{
@ -15,14 +16,9 @@ class AppServiceProvider extends ServiceProvider
*/
public function register(): void
{
// @TODO: Is this the best place to run the seeder?
// if (env('APP_ENV') === 'production') {
// dump('Seed default data.');
// Process::run('php artisan db:seed --class=ProductionSeeder --force');
// } else {
// dump('Not in production environment.');
// }
//
if (config('app.env') === 'production' && Str::contains(config('coolify.version'), ['nightly'])) {
Process::run('php artisan migrate:fresh --force --seed --seeder=ProductionSeeder');
}
}
/**
@ -31,9 +27,8 @@ public function register(): void
public function boot(): void
{
Queue::after(function (JobProcessed $event) {
// @TODO: Remove `coolify-builder` container after the remoteProcess job is finishged and remoteProcess->type == `deployment`.
// @TODO: Remove `coolify-builder` container after the remoteProcess job is finishged and remoteProcess->type == `deployment`.
if ($event->job->resolveName() === CoolifyTask::class) {
}
});
}