Merge branch 'next' into feature/authentik-provider
This commit is contained in:
22
database/factories/ApplicationFactory.php
Normal file
22
database/factories/ApplicationFactory.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ApplicationFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->unique()->name(),
|
||||
'destination_id' => 1,
|
||||
'git_repository' => fake()->url(),
|
||||
'git_branch' => fake()->word(),
|
||||
'build_pack' => 'nixpacks',
|
||||
'ports_exposes' => '3000',
|
||||
'environment_id' => 1,
|
||||
'destination_id' => 1,
|
||||
];
|
||||
}
|
||||
}
|
||||
17
database/factories/ServerFactory.php
Normal file
17
database/factories/ServerFactory.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ServerFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->unique()->name(),
|
||||
'ip' => fake()->unique()->ipv4(),
|
||||
'private_key_id' => 1,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ return new class extends Migration
|
||||
{
|
||||
Schema::table('subscriptions', function (Blueprint $table) {
|
||||
$table->string('stripe_plan_id')->nullable()->after('stripe_cancel_at_period_end');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ return new class extends Migration
|
||||
Schema::table('subscriptions', function (Blueprint $table) {
|
||||
$table->string('stripe_feedback')->nullable()->after('stripe_cancel_at_period_end');
|
||||
$table->string('stripe_comment')->nullable()->after('stripe_feedback');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ return new class extends Migration
|
||||
{
|
||||
Schema::table('subscriptions', function (Blueprint $table) {
|
||||
$table->boolean('stripe_trial_already_ended')->default(false)->after('stripe_cancel_at_period_end');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ return new class extends Migration
|
||||
{
|
||||
Schema::table('team_invitations', function (Blueprint $table) {
|
||||
$table->text('link')->change();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ return new class extends Migration
|
||||
$table->longText('description')->nullable();
|
||||
$table->longText('docker_compose_raw');
|
||||
$table->longText('docker_compose')->nullable();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ return new class extends Migration
|
||||
{
|
||||
Schema::table('environment_variables', function (Blueprint $table) {
|
||||
$table->foreignId('service_id')->nullable();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ return new class extends Migration
|
||||
Schema::table('services', function (Blueprint $table) {
|
||||
$table->dropColumn('destination_type');
|
||||
$table->dropColumn('destination_id');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,5 @@ return new class extends Migration
|
||||
$table->dropColumn('unreachable_email_sent');
|
||||
$table->integer('unreachable_count')->default(0);
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,7 +22,6 @@ return new class extends Migration
|
||||
$table->boolean('is_logdrain_axiom_enabled')->default(false);
|
||||
$table->string('logdrain_axiom_dataset_name')->nullable();
|
||||
$table->string('logdrain_axiom_api_key')->nullable();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,5 @@ return new class extends Migration
|
||||
Schema::table('service_databases', function (Blueprint $table) {
|
||||
$table->dropSoftDeletes();
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -14,7 +14,6 @@ return new class extends Migration
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->string('docker_compose_custom_start_command')->nullable();
|
||||
$table->string('docker_compose_custom_build_command')->nullable();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ return new class extends Migration
|
||||
{
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->text('custom_docker_run_options')->nullable()->change();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ return new class extends Migration
|
||||
{
|
||||
Schema::table('application_settings', function (Blueprint $table) {
|
||||
$table->boolean('connect_to_docker_network')->default(false);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ return new class extends Migration
|
||||
{
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->string('manual_webhook_secret_gitea')->nullable();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->string('redirect')->enum('www', 'non-www', 'both')->default('both')->after('domain');
|
||||
$table->enum('redirect', ['www', 'non-www', 'both'])->default('both')->after('domain');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ return new class extends Migration
|
||||
$table->boolean('is_metrics_enabled')->default(false);
|
||||
$table->integer('metrics_refresh_rate_seconds')->default(5);
|
||||
$table->integer('metrics_history_days')->default(30);
|
||||
$table->string('metrics_token')->default(generateSentinelToken());
|
||||
$table->string('metrics_token')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ use App\Models\EnvironmentVariable;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Visus\Cuid2\Cuid2;
|
||||
|
||||
@@ -14,44 +16,45 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->dropColumn('docker_compose_pr_location');
|
||||
$table->dropColumn('docker_compose_pr');
|
||||
$table->dropColumn('docker_compose_pr_raw');
|
||||
});
|
||||
Schema::table('subscriptions', function (Blueprint $table) {
|
||||
$table->dropColumn('lemon_subscription_id');
|
||||
$table->dropColumn('lemon_order_id');
|
||||
$table->dropColumn('lemon_product_id');
|
||||
$table->dropColumn('lemon_variant_id');
|
||||
$table->dropColumn('lemon_variant_name');
|
||||
$table->dropColumn('lemon_customer_id');
|
||||
$table->dropColumn('lemon_status');
|
||||
$table->dropColumn('lemon_renews_at');
|
||||
$table->dropColumn('lemon_update_payment_menthod_url');
|
||||
$table->dropColumn('lemon_trial_ends_at');
|
||||
$table->dropColumn('lemon_ends_at');
|
||||
});
|
||||
Schema::table('environment_variables', function (Blueprint $table) {
|
||||
$table->string('uuid')->nullable()->after('id');
|
||||
});
|
||||
try {
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->dropColumn('docker_compose_pr_location');
|
||||
$table->dropColumn('docker_compose_pr');
|
||||
$table->dropColumn('docker_compose_pr_raw');
|
||||
});
|
||||
Schema::table('subscriptions', function (Blueprint $table) {
|
||||
$table->dropColumn('lemon_subscription_id');
|
||||
$table->dropColumn('lemon_order_id');
|
||||
$table->dropColumn('lemon_product_id');
|
||||
$table->dropColumn('lemon_variant_id');
|
||||
$table->dropColumn('lemon_variant_name');
|
||||
$table->dropColumn('lemon_customer_id');
|
||||
$table->dropColumn('lemon_status');
|
||||
$table->dropColumn('lemon_renews_at');
|
||||
$table->dropColumn('lemon_update_payment_menthod_url');
|
||||
$table->dropColumn('lemon_trial_ends_at');
|
||||
$table->dropColumn('lemon_ends_at');
|
||||
});
|
||||
Schema::table('environment_variables', function (Blueprint $table) {
|
||||
$table->string('uuid')->nullable()->after('id');
|
||||
});
|
||||
|
||||
EnvironmentVariable::all()->each(function (EnvironmentVariable $environmentVariable) {
|
||||
$environmentVariable->update([
|
||||
'uuid' => (string) new Cuid2,
|
||||
]);
|
||||
});
|
||||
Schema::table('environment_variables', function (Blueprint $table) {
|
||||
$table->string('uuid')->nullable(false)->change();
|
||||
});
|
||||
Schema::table('server_settings', function (Blueprint $table) {
|
||||
$table->integer('metrics_history_days')->default(7)->change();
|
||||
});
|
||||
Server::all()->each(function (Server $server) {
|
||||
$server->settings->update([
|
||||
'metrics_history_days' => 7,
|
||||
]);
|
||||
});
|
||||
EnvironmentVariable::all()->each(function (EnvironmentVariable $environmentVariable) {
|
||||
$environmentVariable->update([
|
||||
'uuid' => (string) new Cuid2,
|
||||
]);
|
||||
});
|
||||
Schema::table('environment_variables', function (Blueprint $table) {
|
||||
$table->string('uuid')->nullable(false)->change();
|
||||
});
|
||||
Schema::table('server_settings', function (Blueprint $table) {
|
||||
$table->integer('metrics_history_days')->default(7)->change();
|
||||
});
|
||||
|
||||
DB::table('server_settings')->update(['metrics_history_days' => 7]);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Error updating db: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,7 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('server_settings', function (Blueprint $table) {
|
||||
$table->boolean('is_force_cleanup_enabled')->default(false)->after('is_sentinel_enabled');
|
||||
$table->boolean('is_force_cleanup_enabled')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ class AddServerCleanupFieldsToServerSettingsTable extends Migration
|
||||
$serverSetting->docker_cleanup_threshold = $serverSetting->cleanup_after_percentage;
|
||||
$serverSetting->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,5 @@ class EncryptExistingPrivateKeys extends Migration
|
||||
echo 'Encrypting private keys failed.';
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('server_settings', function (Blueprint $table) {
|
||||
$table->dropColumn('metrics_token');
|
||||
$table->dropColumn('metrics_refresh_rate_seconds');
|
||||
$table->dropColumn('metrics_history_days');
|
||||
$table->dropColumn('is_server_api_enabled');
|
||||
|
||||
$table->boolean('is_sentinel_enabled')->default(false);
|
||||
$table->text('sentinel_token')->nullable();
|
||||
$table->integer('sentinel_metrics_refresh_rate_seconds')->default(10);
|
||||
$table->integer('sentinel_metrics_history_days')->default(7);
|
||||
$table->integer('sentinel_push_interval_seconds')->default(60);
|
||||
$table->string('sentinel_custom_url')->nullable();
|
||||
});
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->dateTime('sentinel_updated_at')->default(now());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('server_settings', function (Blueprint $table) {
|
||||
$table->string('metrics_token')->nullable();
|
||||
$table->integer('metrics_refresh_rate_seconds')->default(5);
|
||||
$table->integer('metrics_history_days')->default(30);
|
||||
$table->boolean('is_server_api_enabled')->default(false);
|
||||
|
||||
$table->dropColumn('is_sentinel_enabled');
|
||||
$table->dropColumn('sentinel_token');
|
||||
$table->dropColumn('sentinel_metrics_refresh_rate_seconds');
|
||||
$table->dropColumn('sentinel_metrics_history_days');
|
||||
$table->dropColumn('sentinel_push_interval_seconds');
|
||||
$table->dropColumn('sentinel_custom_url');
|
||||
});
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->dropColumn('sentinel_updated_at');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddIsSharedToEnvironmentVariables extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('environment_variables', function (Blueprint $table) {
|
||||
$table->boolean('is_shared')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('environment_variables', function (Blueprint $table) {
|
||||
$table->dropColumn('is_shared');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use App\Models\EnvironmentVariable;
|
||||
use App\Models\StandaloneRedis;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class MoveRedisPasswordToEnvs extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
StandaloneRedis::chunkById(100, function ($redisInstances) {
|
||||
foreach ($redisInstances as $redis) {
|
||||
$redis_password = DB::table('standalone_redis')->where('id', $redis->id)->value('redis_password');
|
||||
EnvironmentVariable::create([
|
||||
'standalone_redis_id' => $redis->id,
|
||||
'key' => 'REDIS_PASSWORD',
|
||||
'value' => $redis_password,
|
||||
]);
|
||||
EnvironmentVariable::create([
|
||||
'standalone_redis_id' => $redis->id,
|
||||
'key' => 'REDIS_USERNAME',
|
||||
'value' => 'default',
|
||||
]);
|
||||
}
|
||||
});
|
||||
Schema::table('standalone_redis', function (Blueprint $table) {
|
||||
$table->dropColumn('redis_password');
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
echo 'Moving Redis passwords to envs failed.';
|
||||
echo $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('instance_settings', function (Blueprint $table) {
|
||||
$table->boolean('disable_two_step_confirmation')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('instance_settings', function (Blueprint $table) {
|
||||
$table->dropColumn('disable_two_step_confirmation');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->dropSoftDeletes();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('server_settings', function (Blueprint $table) {
|
||||
$table->integer('server_disk_usage_notification_threshold')->default(80)->after('docker_cleanup_threshold');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('server_settings', function (Blueprint $table) {
|
||||
$table->dropColumn('server_disk_usage_notification_threshold');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('teams', function (Blueprint $table) {
|
||||
$table->boolean('discord_notifications_server_disk_usage')->default(true)->after('discord_enabled');
|
||||
$table->boolean('smtp_notifications_server_disk_usage')->default(true)->after('smtp_enabled');
|
||||
$table->boolean('telegram_notifications_server_disk_usage')->default(true)->after('telegram_enabled');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('teams', function (Blueprint $table) {
|
||||
$table->dropColumn('discord_notifications_server_disk_usage');
|
||||
$table->dropColumn('smtp_notifications_server_disk_usage');
|
||||
$table->dropColumn('telegram_notifications_server_disk_usage');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('server_settings', function (Blueprint $table) {
|
||||
$table->boolean('is_sentinel_debug_enabled')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('server_settings', function (Blueprint $table) {
|
||||
$table->dropColumn('is_sentinel_debug_enabled');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
use App\Models\PersonalAccessToken;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
try {
|
||||
$tokens = PersonalAccessToken::all();
|
||||
foreach ($tokens as $token) {
|
||||
$abilities = collect();
|
||||
if (in_array('*', $token->abilities)) {
|
||||
$abilities->push('root');
|
||||
}
|
||||
if (in_array('read-only', $token->abilities)) {
|
||||
$abilities->push('read');
|
||||
}
|
||||
if (in_array('view:sensitive', $token->abilities)) {
|
||||
$abilities->push('read', 'read:sensitive');
|
||||
}
|
||||
$token->abilities = $abilities->unique()->values()->all();
|
||||
$token->save();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('Error renaming token permissions: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
try {
|
||||
$tokens = PersonalAccessToken::all();
|
||||
foreach ($tokens as $token) {
|
||||
$abilities = collect();
|
||||
if (in_array('write', $token->abilities)) {
|
||||
$abilities->push('*');
|
||||
} else {
|
||||
if (in_array('read', $token->abilities)) {
|
||||
$abilities->push('read-only');
|
||||
}
|
||||
if (in_array('read:sensitive', $token->abilities)) {
|
||||
$abilities->push('view:sensitive');
|
||||
}
|
||||
}
|
||||
$token->abilities = $abilities->unique()->values()->all();
|
||||
$token->save();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('Error renaming token permissions: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->timestamp('last_online_at')->default(now())->after('updated_at');
|
||||
});
|
||||
Schema::table('application_previews', function (Blueprint $table) {
|
||||
$table->timestamp('last_online_at')->default(now())->after('updated_at');
|
||||
});
|
||||
Schema::table('service_applications', function (Blueprint $table) {
|
||||
$table->timestamp('last_online_at')->default(now())->after('updated_at');
|
||||
});
|
||||
Schema::table('service_databases', function (Blueprint $table) {
|
||||
$table->timestamp('last_online_at')->default(now())->after('updated_at');
|
||||
});
|
||||
Schema::table('standalone_postgresqls', function (Blueprint $table) {
|
||||
$table->timestamp('last_online_at')->default(now())->after('updated_at');
|
||||
});
|
||||
Schema::table('standalone_redis', function (Blueprint $table) {
|
||||
$table->timestamp('last_online_at')->default(now())->after('updated_at');
|
||||
});
|
||||
Schema::table('standalone_mongodbs', function (Blueprint $table) {
|
||||
$table->timestamp('last_online_at')->default(now())->after('updated_at');
|
||||
});
|
||||
Schema::table('standalone_mysqls', function (Blueprint $table) {
|
||||
$table->timestamp('last_online_at')->default(now())->after('updated_at');
|
||||
});
|
||||
Schema::table('standalone_mariadbs', function (Blueprint $table) {
|
||||
$table->timestamp('last_online_at')->default(now())->after('updated_at');
|
||||
});
|
||||
Schema::table('standalone_keydbs', function (Blueprint $table) {
|
||||
$table->timestamp('last_online_at')->default(now())->after('updated_at');
|
||||
});
|
||||
Schema::table('standalone_dragonflies', function (Blueprint $table) {
|
||||
$table->timestamp('last_online_at')->default(now())->after('updated_at');
|
||||
});
|
||||
Schema::table('standalone_clickhouses', function (Blueprint $table) {
|
||||
$table->timestamp('last_online_at')->default(now())->after('updated_at');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->dropColumn('last_online_at');
|
||||
});
|
||||
Schema::table('application_previews', function (Blueprint $table) {
|
||||
$table->dropColumn('last_online_at');
|
||||
});
|
||||
Schema::table('service_applications', function (Blueprint $table) {
|
||||
$table->dropColumn('last_online_at');
|
||||
});
|
||||
Schema::table('service_databases', function (Blueprint $table) {
|
||||
$table->dropColumn('last_online_at');
|
||||
});
|
||||
Schema::table('standalone_postgresqls', function (Blueprint $table) {
|
||||
$table->dropColumn('last_online_at');
|
||||
});
|
||||
Schema::table('standalone_redis', function (Blueprint $table) {
|
||||
$table->dropColumn('last_online_at');
|
||||
});
|
||||
Schema::table('standalone_mongodbs', function (Blueprint $table) {
|
||||
$table->dropColumn('last_online_at');
|
||||
});
|
||||
Schema::table('standalone_mysqls', function (Blueprint $table) {
|
||||
$table->dropColumn('last_online_at');
|
||||
});
|
||||
Schema::table('standalone_mariadbs', function (Blueprint $table) {
|
||||
$table->dropColumn('last_online_at');
|
||||
});
|
||||
Schema::table('standalone_keydbs', function (Blueprint $table) {
|
||||
$table->dropColumn('last_online_at');
|
||||
});
|
||||
Schema::table('standalone_dragonflies', function (Blueprint $table) {
|
||||
$table->dropColumn('last_online_at');
|
||||
});
|
||||
Schema::table('standalone_clickhouses', function (Blueprint $table) {
|
||||
$table->dropColumn('last_online_at');
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->longText('custom_nginx_configuration')->nullable()->after('static_image');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->dropColumn('custom_nginx_configuration');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class AddIndexToActivityLog extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
try {
|
||||
DB::statement('ALTER TABLE activity_log ALTER COLUMN properties TYPE jsonb USING properties::jsonb');
|
||||
DB::statement('CREATE INDEX idx_activity_type_uuid ON activity_log USING GIN (properties jsonb_path_ops)');
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Error adding index to activity_log: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
try {
|
||||
DB::statement('DROP INDEX IF EXISTS idx_activity_type_uuid');
|
||||
DB::statement('ALTER TABLE activity_log ALTER COLUMN properties TYPE json USING properties::json');
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Error dropping index from activity_log: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('application_settings', function (Blueprint $table) {
|
||||
$table->boolean('disable_build_cache')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('application_settings', function (Blueprint $table) {
|
||||
$table->dropColumn('disable_build_cache');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('email_notification_settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('team_id')->constrained()->cascadeOnDelete();
|
||||
|
||||
$table->boolean('smtp_enabled')->default(false);
|
||||
$table->text('smtp_from_address')->nullable();
|
||||
$table->text('smtp_from_name')->nullable();
|
||||
$table->text('smtp_recipients')->nullable();
|
||||
$table->text('smtp_host')->nullable();
|
||||
$table->integer('smtp_port')->nullable();
|
||||
$table->string('smtp_encryption')->nullable();
|
||||
$table->text('smtp_username')->nullable();
|
||||
$table->text('smtp_password')->nullable();
|
||||
$table->integer('smtp_timeout')->nullable();
|
||||
|
||||
$table->boolean('resend_enabled')->default(false);
|
||||
$table->text('resend_api_key')->nullable();
|
||||
|
||||
$table->boolean('use_instance_email_settings')->default(false);
|
||||
|
||||
$table->boolean('deployment_success_email_notifications')->default(false);
|
||||
$table->boolean('deployment_failure_email_notifications')->default(true);
|
||||
$table->boolean('status_change_email_notifications')->default(false);
|
||||
$table->boolean('backup_success_email_notifications')->default(false);
|
||||
$table->boolean('backup_failure_email_notifications')->default(true);
|
||||
$table->boolean('scheduled_task_success_email_notifications')->default(false);
|
||||
$table->boolean('scheduled_task_failure_email_notifications')->default(true);
|
||||
$table->boolean('docker_cleanup_success_email_notifications')->default(false);
|
||||
$table->boolean('docker_cleanup_failure_email_notifications')->default(true);
|
||||
$table->boolean('server_disk_usage_email_notifications')->default(true);
|
||||
$table->boolean('server_reachable_email_notifications')->default(false);
|
||||
$table->boolean('server_unreachable_email_notifications')->default(true);
|
||||
|
||||
$table->unique(['team_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('email_notification_settings');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('discord_notification_settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('team_id')->constrained()->cascadeOnDelete();
|
||||
|
||||
$table->boolean('discord_enabled')->default(false);
|
||||
$table->text('discord_webhook_url')->nullable();
|
||||
|
||||
$table->boolean('deployment_success_discord_notifications')->default(false);
|
||||
$table->boolean('deployment_failure_discord_notifications')->default(true);
|
||||
$table->boolean('status_change_discord_notifications')->default(false);
|
||||
$table->boolean('backup_success_discord_notifications')->default(false);
|
||||
$table->boolean('backup_failure_discord_notifications')->default(true);
|
||||
$table->boolean('scheduled_task_success_discord_notifications')->default(false);
|
||||
$table->boolean('scheduled_task_failure_discord_notifications')->default(true);
|
||||
$table->boolean('docker_cleanup_success_discord_notifications')->default(false);
|
||||
$table->boolean('docker_cleanup_failure_discord_notifications')->default(true);
|
||||
$table->boolean('server_disk_usage_discord_notifications')->default(true);
|
||||
$table->boolean('server_reachable_discord_notifications')->default(false);
|
||||
$table->boolean('server_unreachable_discord_notifications')->default(true);
|
||||
|
||||
$table->unique(['team_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('discord_notification_settings');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('telegram_notification_settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('team_id')->constrained()->cascadeOnDelete();
|
||||
|
||||
$table->boolean('telegram_enabled')->default(false);
|
||||
$table->text('telegram_token')->nullable();
|
||||
$table->text('telegram_chat_id')->nullable();
|
||||
|
||||
$table->boolean('deployment_success_telegram_notifications')->default(false);
|
||||
$table->boolean('deployment_failure_telegram_notifications')->default(true);
|
||||
$table->boolean('status_change_telegram_notifications')->default(false);
|
||||
$table->boolean('backup_success_telegram_notifications')->default(false);
|
||||
$table->boolean('backup_failure_telegram_notifications')->default(true);
|
||||
$table->boolean('scheduled_task_success_telegram_notifications')->default(false);
|
||||
$table->boolean('scheduled_task_failure_telegram_notifications')->default(true);
|
||||
$table->boolean('docker_cleanup_success_telegram_notifications')->default(false);
|
||||
$table->boolean('docker_cleanup_failure_telegram_notifications')->default(true);
|
||||
$table->boolean('server_disk_usage_telegram_notifications')->default(true);
|
||||
$table->boolean('server_reachable_telegram_notifications')->default(false);
|
||||
$table->boolean('server_unreachable_telegram_notifications')->default(true);
|
||||
|
||||
$table->text('telegram_notifications_deployment_success_topic_id')->nullable();
|
||||
$table->text('telegram_notifications_deployment_failure_topic_id')->nullable();
|
||||
$table->text('telegram_notifications_status_change_topic_id')->nullable();
|
||||
$table->text('telegram_notifications_backup_success_topic_id')->nullable();
|
||||
$table->text('telegram_notifications_backup_failure_topic_id')->nullable();
|
||||
$table->text('telegram_notifications_scheduled_task_success_topic_id')->nullable();
|
||||
$table->text('telegram_notifications_scheduled_task_failure_topic_id')->nullable();
|
||||
$table->text('telegram_notifications_docker_cleanup_success_topic_id')->nullable();
|
||||
$table->text('telegram_notifications_docker_cleanup_failure_topic_id')->nullable();
|
||||
$table->text('telegram_notifications_server_disk_usage_topic_id')->nullable();
|
||||
$table->text('telegram_notifications_server_reachable_topic_id')->nullable();
|
||||
$table->text('telegram_notifications_server_unreachable_topic_id')->nullable();
|
||||
|
||||
$table->unique(['team_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('telegram_notification_settings');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$teams = DB::table('teams')->get();
|
||||
|
||||
foreach ($teams as $team) {
|
||||
try {
|
||||
DB::table('email_notification_settings')->updateOrInsert(
|
||||
['team_id' => $team->id],
|
||||
[
|
||||
'smtp_enabled' => $team->smtp_enabled ?? false,
|
||||
'smtp_from_address' => $team->smtp_from_address ? Crypt::encryptString($team->smtp_from_address) : null,
|
||||
'smtp_from_name' => $team->smtp_from_name ? Crypt::encryptString($team->smtp_from_name) : null,
|
||||
'smtp_recipients' => $team->smtp_recipients ? Crypt::encryptString($team->smtp_recipients) : null,
|
||||
'smtp_host' => $team->smtp_host ? Crypt::encryptString($team->smtp_host) : null,
|
||||
'smtp_port' => $team->smtp_port,
|
||||
'smtp_encryption' => $team->smtp_encryption,
|
||||
'smtp_username' => $team->smtp_username ? Crypt::encryptString($team->smtp_username) : null,
|
||||
'smtp_password' => $team->smtp_password,
|
||||
'smtp_timeout' => $team->smtp_timeout,
|
||||
|
||||
'use_instance_email_settings' => $team->use_instance_email_settings ?? false,
|
||||
|
||||
'resend_enabled' => $team->resend_enabled ?? false,
|
||||
'resend_api_key' => $team->resend_api_key,
|
||||
|
||||
'deployment_success_email_notifications' => $team->smtp_notifications_deployments ?? false,
|
||||
'deployment_failure_email_notifications' => $team->smtp_notifications_deployments ?? true,
|
||||
'backup_success_email_notifications' => $team->smtp_notifications_database_backups ?? false,
|
||||
'backup_failure_email_notifications' => $team->smtp_notifications_database_backups ?? true,
|
||||
'scheduled_task_success_email_notifications' => $team->smtp_notifications_scheduled_tasks ?? false,
|
||||
'scheduled_task_failure_email_notifications' => $team->smtp_notifications_scheduled_tasks ?? true,
|
||||
'status_change_email_notifications' => $team->smtp_notifications_status_changes ?? false,
|
||||
'server_disk_usage_email_notifications' => $team->smtp_notifications_server_disk_usage ?? true,
|
||||
]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
\Log::error('Error migrating email notification settings from teams table: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Schema::table('teams', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'smtp_enabled',
|
||||
'smtp_from_address',
|
||||
'smtp_from_name',
|
||||
'smtp_recipients',
|
||||
'smtp_host',
|
||||
'smtp_port',
|
||||
'smtp_encryption',
|
||||
'smtp_username',
|
||||
'smtp_password',
|
||||
'smtp_timeout',
|
||||
'use_instance_email_settings',
|
||||
'resend_enabled',
|
||||
'resend_api_key',
|
||||
'smtp_notifications_test',
|
||||
'smtp_notifications_deployments',
|
||||
'smtp_notifications_database_backups',
|
||||
'smtp_notifications_scheduled_tasks',
|
||||
'smtp_notifications_status_changes',
|
||||
'smtp_notifications_server_disk_usage',
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('teams', function (Blueprint $table) {
|
||||
$table->boolean('smtp_enabled')->default(false);
|
||||
$table->string('smtp_from_address')->nullable();
|
||||
$table->string('smtp_from_name')->nullable();
|
||||
$table->string('smtp_recipients')->nullable();
|
||||
$table->string('smtp_host')->nullable();
|
||||
$table->integer('smtp_port')->nullable();
|
||||
$table->string('smtp_encryption')->nullable();
|
||||
$table->text('smtp_username')->nullable();
|
||||
$table->text('smtp_password')->nullable();
|
||||
$table->integer('smtp_timeout')->nullable();
|
||||
|
||||
$table->boolean('use_instance_email_settings')->default(false);
|
||||
$table->boolean('resend_enabled')->default(false);
|
||||
|
||||
$table->text('resend_api_key')->nullable();
|
||||
|
||||
$table->boolean('smtp_notifications_test')->default(false);
|
||||
$table->boolean('smtp_notifications_deployments')->default(false);
|
||||
$table->boolean('smtp_notifications_database_backups')->default(true);
|
||||
$table->boolean('smtp_notifications_scheduled_tasks')->default(false);
|
||||
$table->boolean('smtp_notifications_status_changes')->default(false);
|
||||
$table->boolean('smtp_notifications_server_disk_usage')->default(true);
|
||||
});
|
||||
|
||||
$settings = DB::table('email_notification_settings')->get();
|
||||
foreach ($settings as $setting) {
|
||||
try {
|
||||
DB::table('teams')
|
||||
->where('id', $setting->team_id)
|
||||
->update([
|
||||
'smtp_enabled' => $setting->smtp_enabled,
|
||||
'smtp_from_address' => $setting->smtp_from_address ? Crypt::decryptString($setting->smtp_from_address) : null,
|
||||
'smtp_from_name' => $setting->smtp_from_name ? Crypt::decryptString($setting->smtp_from_name) : null,
|
||||
'smtp_recipients' => $setting->smtp_recipients ? Crypt::decryptString($setting->smtp_recipients) : null,
|
||||
'smtp_host' => $setting->smtp_host ? Crypt::decryptString($setting->smtp_host) : null,
|
||||
'smtp_port' => $setting->smtp_port,
|
||||
'smtp_encryption' => $setting->smtp_encryption,
|
||||
'smtp_username' => $setting->smtp_username ? Crypt::decryptString($setting->smtp_username) : null,
|
||||
'smtp_password' => $setting->smtp_password,
|
||||
'smtp_timeout' => $setting->smtp_timeout,
|
||||
|
||||
'use_instance_email_settings' => $setting->use_instance_email_settings,
|
||||
|
||||
'resend_enabled' => $setting->resend_enabled,
|
||||
'resend_api_key' => $setting->resend_api_key,
|
||||
|
||||
'smtp_notifications_deployments' => $setting->deployment_success_email_notifications || $setting->deployment_failure_email_notifications,
|
||||
'smtp_notifications_database_backups' => $setting->backup_success_email_notifications || $setting->backup_failure_email_notifications,
|
||||
'smtp_notifications_scheduled_tasks' => $setting->scheduled_task_success_email_notifications || $setting->scheduled_task_failure_email_notifications,
|
||||
'smtp_notifications_status_changes' => $setting->status_change_email_notifications,
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
\Log::error('Error migrating email notification settings from teams table: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$teams = DB::table('teams')->get();
|
||||
|
||||
foreach ($teams as $team) {
|
||||
try {
|
||||
DB::table('discord_notification_settings')->updateOrInsert(
|
||||
['team_id' => $team->id],
|
||||
[
|
||||
'discord_enabled' => $team->discord_enabled ?? false,
|
||||
'discord_webhook_url' => $team->discord_webhook_url ? Crypt::encryptString($team->discord_webhook_url) : null,
|
||||
|
||||
'deployment_success_discord_notifications' => $team->discord_notifications_deployments ?? false,
|
||||
'deployment_failure_discord_notifications' => $team->discord_notifications_deployments ?? true,
|
||||
'backup_success_discord_notifications' => $team->discord_notifications_database_backups ?? false,
|
||||
'backup_failure_discord_notifications' => $team->discord_notifications_database_backups ?? true,
|
||||
'scheduled_task_success_discord_notifications' => $team->discord_notifications_scheduled_tasks ?? false,
|
||||
'scheduled_task_failure_discord_notifications' => $team->discord_notifications_scheduled_tasks ?? true,
|
||||
'status_change_discord_notifications' => $team->discord_notifications_status_changes ?? false,
|
||||
'server_disk_usage_discord_notifications' => $team->discord_notifications_server_disk_usage ?? true,
|
||||
]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
\Log::error('Error migrating discord notification settings from teams table: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Schema::table('teams', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'discord_enabled',
|
||||
'discord_webhook_url',
|
||||
'discord_notifications_test',
|
||||
'discord_notifications_deployments',
|
||||
'discord_notifications_status_changes',
|
||||
'discord_notifications_database_backups',
|
||||
'discord_notifications_scheduled_tasks',
|
||||
'discord_notifications_server_disk_usage',
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('teams', function (Blueprint $table) {
|
||||
$table->boolean('discord_enabled')->default(false);
|
||||
$table->string('discord_webhook_url')->nullable();
|
||||
|
||||
$table->boolean('discord_notifications_test')->default(true);
|
||||
$table->boolean('discord_notifications_deployments')->default(true);
|
||||
$table->boolean('discord_notifications_status_changes')->default(true);
|
||||
$table->boolean('discord_notifications_database_backups')->default(true);
|
||||
$table->boolean('discord_notifications_scheduled_tasks')->default(true);
|
||||
$table->boolean('discord_notifications_server_disk_usage')->default(true);
|
||||
});
|
||||
|
||||
$settings = DB::table('discord_notification_settings')->get();
|
||||
foreach ($settings as $setting) {
|
||||
try {
|
||||
DB::table('teams')
|
||||
->where('id', $setting->team_id)
|
||||
->update([
|
||||
'discord_enabled' => $setting->discord_enabled,
|
||||
'discord_webhook_url' => Crypt::decryptString($setting->discord_webhook_url),
|
||||
|
||||
'discord_notifications_deployments' => $setting->deployment_success_discord_notifications || $setting->deployment_failure_discord_notifications,
|
||||
'discord_notifications_status_changes' => $setting->status_change_discord_notifications,
|
||||
'discord_notifications_database_backups' => $setting->backup_success_discord_notifications || $setting->backup_failure_discord_notifications,
|
||||
'discord_notifications_scheduled_tasks' => $setting->scheduled_task_success_discord_notifications || $setting->scheduled_task_failure_discord_notifications,
|
||||
'discord_notifications_server_disk_usage' => $setting->server_disk_usage_discord_notifications,
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
\Log::error('Error migrating discord notification settings from teams table: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$teams = DB::table('teams')->get();
|
||||
|
||||
foreach ($teams as $team) {
|
||||
try {
|
||||
DB::table('telegram_notification_settings')->updateOrInsert(
|
||||
['team_id' => $team->id],
|
||||
[
|
||||
'telegram_enabled' => $team->telegram_enabled ?? false,
|
||||
'telegram_token' => $team->telegram_token ? Crypt::encryptString($team->telegram_token) : null,
|
||||
'telegram_chat_id' => $team->telegram_chat_id ? Crypt::encryptString($team->telegram_chat_id) : null,
|
||||
|
||||
'deployment_success_telegram_notifications' => $team->telegram_notifications_deployments ?? false,
|
||||
'deployment_failure_telegram_notifications' => $team->telegram_notifications_deployments ?? true,
|
||||
'backup_success_telegram_notifications' => $team->telegram_notifications_database_backups ?? false,
|
||||
'backup_failure_telegram_notifications' => $team->telegram_notifications_database_backups ?? true,
|
||||
'scheduled_task_success_telegram_notifications' => $team->telegram_notifications_scheduled_tasks ?? false,
|
||||
'scheduled_task_failure_telegram_notifications' => $team->telegram_notifications_scheduled_tasks ?? true,
|
||||
'status_change_telegram_notifications' => $team->telegram_notifications_status_changes ?? false,
|
||||
'server_disk_usage_telegram_notifications' => $team->telegram_notifications_server_disk_usage ?? true,
|
||||
|
||||
'telegram_notifications_deployment_success_topic_id' => $team->telegram_notifications_deployments_message_thread_id ? Crypt::encryptString($team->telegram_notifications_deployments_message_thread_id) : null,
|
||||
'telegram_notifications_deployment_failure_topic_id' => $team->telegram_notifications_deployments_message_thread_id ? Crypt::encryptString($team->telegram_notifications_deployments_message_thread_id) : null,
|
||||
'telegram_notifications_backup_success_topic_id' => $team->telegram_notifications_database_backups_message_thread_id ? Crypt::encryptString($team->telegram_notifications_database_backups_message_thread_id) : null,
|
||||
'telegram_notifications_backup_failure_topic_id' => $team->telegram_notifications_database_backups_message_thread_id ? Crypt::encryptString($team->telegram_notifications_database_backups_message_thread_id) : null,
|
||||
'telegram_notifications_scheduled_task_success_topic_id' => $team->telegram_notifications_scheduled_tasks_thread_id ? Crypt::encryptString($team->telegram_notifications_scheduled_tasks_thread_id) : null,
|
||||
'telegram_notifications_scheduled_task_failure_topic_id' => $team->telegram_notifications_scheduled_tasks_thread_id ? Crypt::encryptString($team->telegram_notifications_scheduled_tasks_thread_id) : null,
|
||||
'telegram_notifications_status_change_topic_id' => $team->telegram_notifications_status_changes_message_thread_id ? Crypt::encryptString($team->telegram_notifications_status_changes_message_thread_id) : null,
|
||||
]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
\Log::error('Error migrating telegram notification settings from teams table: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Schema::table('teams', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'telegram_enabled',
|
||||
'telegram_token',
|
||||
'telegram_chat_id',
|
||||
'telegram_notifications_test',
|
||||
'telegram_notifications_deployments',
|
||||
'telegram_notifications_status_changes',
|
||||
'telegram_notifications_database_backups',
|
||||
'telegram_notifications_scheduled_tasks',
|
||||
'telegram_notifications_server_disk_usage',
|
||||
'telegram_notifications_test_message_thread_id',
|
||||
'telegram_notifications_deployments_message_thread_id',
|
||||
'telegram_notifications_status_changes_message_thread_id',
|
||||
'telegram_notifications_database_backups_message_thread_id',
|
||||
'telegram_notifications_scheduled_tasks_thread_id',
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('teams', function (Blueprint $table) {
|
||||
$table->boolean('telegram_enabled')->default(false);
|
||||
$table->text('telegram_token')->nullable();
|
||||
$table->text('telegram_chat_id')->nullable();
|
||||
|
||||
$table->boolean('telegram_notifications_test')->default(true);
|
||||
$table->boolean('telegram_notifications_deployments')->default(true);
|
||||
$table->boolean('telegram_notifications_status_changes')->default(true);
|
||||
$table->boolean('telegram_notifications_database_backups')->default(true);
|
||||
$table->boolean('telegram_notifications_scheduled_tasks')->default(true);
|
||||
$table->boolean('telegram_notifications_server_disk_usage')->default(true);
|
||||
|
||||
$table->text('telegram_notifications_test_message_thread_id')->nullable();
|
||||
$table->text('telegram_notifications_deployments_message_thread_id')->nullable();
|
||||
$table->text('telegram_notifications_status_changes_message_thread_id')->nullable();
|
||||
$table->text('telegram_notifications_database_backups_message_thread_id')->nullable();
|
||||
$table->text('telegram_notifications_scheduled_tasks_thread_id')->nullable();
|
||||
});
|
||||
|
||||
$settings = DB::table('telegram_notification_settings')->get();
|
||||
foreach ($settings as $setting) {
|
||||
try {
|
||||
DB::table('teams')
|
||||
->where('id', $setting->team_id)
|
||||
->update([
|
||||
'telegram_enabled' => $setting->telegram_enabled,
|
||||
'telegram_token' => $setting->telegram_token ? Crypt::decryptString($setting->telegram_token) : null,
|
||||
'telegram_chat_id' => $setting->telegram_chat_id ? Crypt::decryptString($setting->telegram_chat_id) : null,
|
||||
|
||||
'telegram_notifications_deployments' => $setting->deployment_success_telegram_notifications || $setting->deployment_failure_telegram_notifications,
|
||||
'telegram_notifications_status_changes' => $setting->status_change_telegram_notifications,
|
||||
'telegram_notifications_database_backups' => $setting->backup_success_telegram_notifications || $setting->backup_failure_telegram_notifications,
|
||||
'telegram_notifications_scheduled_tasks' => $setting->scheduled_task_success_telegram_notifications || $setting->scheduled_task_failure_telegram_notifications,
|
||||
'telegram_notifications_server_disk_usage' => $setting->server_disk_usage_telegram_notifications,
|
||||
|
||||
'telegram_notifications_deployments_message_thread_id' => $setting->telegram_notifications_deployment_success_topic_id ? Crypt::decryptString($setting->telegram_notifications_deployment_success_topic_id) : null,
|
||||
'telegram_notifications_status_changes_message_thread_id' => $setting->telegram_notifications_status_change_topic_id ? Crypt::decryptString($setting->telegram_notifications_status_change_topic_id) : null,
|
||||
'telegram_notifications_database_backups_message_thread_id' => $setting->telegram_notifications_backup_success_topic_id ? Crypt::decryptString($setting->telegram_notifications_backup_success_topic_id) : null,
|
||||
'telegram_notifications_scheduled_tasks_thread_id' => $setting->telegram_notifications_scheduled_task_success_topic_id ? Crypt::decryptString($setting->telegram_notifications_scheduled_task_success_topic_id) : null,
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
\Log::error('Error migrating telegram notification settings from teams table: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('slack_notification_settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('team_id')->constrained()->cascadeOnDelete();
|
||||
|
||||
$table->boolean('slack_enabled')->default(false);
|
||||
$table->text('slack_webhook_url')->nullable();
|
||||
|
||||
$table->boolean('deployment_success_slack_notifications')->default(false);
|
||||
$table->boolean('deployment_failure_slack_notifications')->default(true);
|
||||
$table->boolean('status_change_slack_notifications')->default(false);
|
||||
$table->boolean('backup_success_slack_notifications')->default(false);
|
||||
$table->boolean('backup_failure_slack_notifications')->default(true);
|
||||
$table->boolean('scheduled_task_success_slack_notifications')->default(false);
|
||||
$table->boolean('scheduled_task_failure_slack_notifications')->default(true);
|
||||
$table->boolean('docker_cleanup_success_slack_notifications')->default(false);
|
||||
$table->boolean('docker_cleanup_failure_slack_notifications')->default(true);
|
||||
$table->boolean('server_disk_usage_slack_notifications')->default(true);
|
||||
$table->boolean('server_reachable_slack_notifications')->default(false);
|
||||
$table->boolean('server_unreachable_slack_notifications')->default(true);
|
||||
|
||||
$table->unique(['team_id']);
|
||||
});
|
||||
$teams = DB::table('teams')->get();
|
||||
|
||||
foreach ($teams as $team) {
|
||||
try {
|
||||
DB::table('slack_notification_settings')->insert([
|
||||
'team_id' => $team->id,
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
\Log::error('Error migrating slack notification settings from teams table: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('slack_notification_settings');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::dropIfExists('waitlists');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::create('waitlists', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid');
|
||||
$table->string('type');
|
||||
$table->string('email')->unique();
|
||||
$table->boolean('verified')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (DB::table('instance_settings')->exists()) {
|
||||
Schema::table('instance_settings', function (Blueprint $table) {
|
||||
$table->text('smtp_from_address')->nullable()->change();
|
||||
$table->text('smtp_from_name')->nullable()->change();
|
||||
$table->text('smtp_recipients')->nullable()->change();
|
||||
$table->text('smtp_host')->nullable()->change();
|
||||
$table->text('smtp_username')->nullable()->change();
|
||||
});
|
||||
|
||||
$settings = DB::table('instance_settings')->get();
|
||||
foreach ($settings as $setting) {
|
||||
try {
|
||||
DB::table('instance_settings')->where('id', $setting->id)->update([
|
||||
'smtp_from_address' => $setting->smtp_from_address ? Crypt::encryptString($setting->smtp_from_address) : null,
|
||||
'smtp_from_name' => $setting->smtp_from_name ? Crypt::encryptString($setting->smtp_from_name) : null,
|
||||
'smtp_recipients' => $setting->smtp_recipients ? Crypt::encryptString($setting->smtp_recipients) : null,
|
||||
'smtp_host' => $setting->smtp_host ? Crypt::encryptString($setting->smtp_host) : null,
|
||||
'smtp_username' => $setting->smtp_username ? Crypt::encryptString($setting->smtp_username) : null,
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
\Log::error('Error encrypting instance settings email columns: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('instance_settings', function (Blueprint $table) {
|
||||
$table->string('smtp_from_address')->nullable()->change();
|
||||
$table->string('smtp_from_name')->nullable()->change();
|
||||
$table->string('smtp_recipients')->nullable()->change();
|
||||
$table->string('smtp_host')->nullable()->change();
|
||||
$table->string('smtp_username')->nullable()->change();
|
||||
});
|
||||
|
||||
if (DB::table('instance_settings')->exists()) {
|
||||
$settings = DB::table('instance_settings')->get();
|
||||
foreach ($settings as $setting) {
|
||||
try {
|
||||
DB::table('instance_settings')->where('id', $setting->id)->update([
|
||||
'smtp_from_address' => $setting->smtp_from_address ? Crypt::decryptString($setting->smtp_from_address) : null,
|
||||
'smtp_from_name' => $setting->smtp_from_name ? Crypt::decryptString($setting->smtp_from_name) : null,
|
||||
'smtp_recipients' => $setting->smtp_recipients ? Crypt::decryptString($setting->smtp_recipients) : null,
|
||||
'smtp_host' => $setting->smtp_host ? Crypt::decryptString($setting->smtp_host) : null,
|
||||
'smtp_username' => $setting->smtp_username ? Crypt::decryptString($setting->smtp_username) : null,
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
\Log::error('Error decrypting instance settings email columns: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('instance_settings', function (Blueprint $table) {
|
||||
$table->dropColumn('is_resale_license_active');
|
||||
$table->dropColumn('resale_license');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('instance_settings', function (Blueprint $table) {
|
||||
$table->boolean('is_resale_license_active')->default(false);
|
||||
$table->longText('resale_license')->nullable();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -26,6 +26,8 @@ class DatabaseSeeder extends Seeder
|
||||
S3StorageSeeder::class,
|
||||
StandalonePostgresqlSeeder::class,
|
||||
OauthSettingSeeder::class,
|
||||
DisableTwoStepConfirmationSeeder::class,
|
||||
SentinelSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
20
database/seeders/DisableTwoStepConfirmationSeeder.php
Normal file
20
database/seeders/DisableTwoStepConfirmationSeeder.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DisableTwoStepConfirmationSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
DB::table('instance_settings')->updateOrInsert(
|
||||
[],
|
||||
['disable_two_step_confirmation' => true]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ class GithubAppSeeder extends Seeder
|
||||
GithubApp::create([
|
||||
'name' => 'coolify-laravel-development-public',
|
||||
'uuid' => '69420',
|
||||
'organization' => 'coollabsio',
|
||||
'api_url' => 'https://api.github.com',
|
||||
'html_url' => 'https://github.com',
|
||||
'is_public' => false,
|
||||
|
||||
@@ -16,7 +16,6 @@ class InstanceSettingsSeeder extends Seeder
|
||||
InstanceSettings::create([
|
||||
'id' => 0,
|
||||
'is_registration_enabled' => true,
|
||||
'is_resale_license_active' => true,
|
||||
'smtp_enabled' => true,
|
||||
'smtp_host' => 'coolify-mail',
|
||||
'smtp_port' => 1025,
|
||||
|
||||
@@ -24,16 +24,14 @@ class PopulateSshKeysDirectorySeeder extends Seeder
|
||||
});
|
||||
|
||||
if (isDev()) {
|
||||
$user = env('PUID').':'.env('PGID');
|
||||
Process::run("chown -R $user ".storage_path('app/ssh/keys'));
|
||||
Process::run("chown -R $user ".storage_path('app/ssh/mux'));
|
||||
Process::run('chown -R 9999:9999 '.storage_path('app/ssh/keys'));
|
||||
Process::run('chown -R 9999:9999 '.storage_path('app/ssh/mux'));
|
||||
} else {
|
||||
Process::run('chown -R 9999:root '.storage_path('app/ssh/keys'));
|
||||
Process::run('chown -R 9999:root '.storage_path('app/ssh/mux'));
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
echo "Error: {$e->getMessage()}\n";
|
||||
ray($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ class ProductionSeeder extends Seeder
|
||||
public function run(): void
|
||||
{
|
||||
if (isCloud()) {
|
||||
echo "Running in cloud mode.\n";
|
||||
echo " Running in cloud mode.\n";
|
||||
} else {
|
||||
echo "Running in self-hosted mode.\n";
|
||||
echo " Running in self-hosted mode.\n";
|
||||
}
|
||||
|
||||
// Fix for 4.0.0-beta.37
|
||||
@@ -100,7 +100,7 @@ class ProductionSeeder extends Seeder
|
||||
}
|
||||
}
|
||||
|
||||
if (! isCloud() && config('coolify.is_windows_docker_desktop') == false) {
|
||||
if (! isCloud() && config('constants.coolify.is_windows_docker_desktop') == false) {
|
||||
$coolify_key_name = '@host.docker.internal';
|
||||
$ssh_keys_directory = Storage::disk('ssh-keys')->files();
|
||||
$coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name));
|
||||
@@ -126,9 +126,8 @@ class ProductionSeeder extends Seeder
|
||||
echo "Your localhost connection won't work until then.";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (config('coolify.is_windows_docker_desktop')) {
|
||||
if (config('constants.coolify.is_windows_docker_desktop')) {
|
||||
PrivateKey::updateOrCreate(
|
||||
[
|
||||
'id' => 0,
|
||||
@@ -186,6 +185,6 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
|
||||
|
||||
$this->call(OauthSettingSeeder::class);
|
||||
$this->call(PopulateSshKeysDirectorySeeder::class);
|
||||
|
||||
$this->call(SentinelSeeder::class);
|
||||
}
|
||||
}
|
||||
|
||||
32
database/seeders/SentinelSeeder.php
Normal file
32
database/seeders/SentinelSeeder.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Server;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SentinelSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
Server::chunk(100, function ($servers) {
|
||||
foreach ($servers as $server) {
|
||||
try {
|
||||
if (str($server->settings->sentinel_token)->isEmpty()) {
|
||||
$server->settings->generateSentinelToken(ignoreEvent: true);
|
||||
}
|
||||
if (str($server->settings->sentinel_custom_url)->isEmpty()) {
|
||||
$url = $server->settings->generateSentinelUrl(ignoreEvent: true);
|
||||
if (str($url)->isEmpty()) {
|
||||
$server->settings->is_sentinel_enabled = false;
|
||||
$server->settings->save();
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('Error seeding sentinel: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Team;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class TestTeamSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
// User has 2 teams, 1 personal, 1 other where it is the owner and no other members are in the team
|
||||
$user = User::factory()->create([
|
||||
'name' => '1 personal, 1 other team, owner, no other members',
|
||||
'email' => '1@example.com',
|
||||
]);
|
||||
$team = Team::create([
|
||||
'name' => '1@example.com',
|
||||
'personal_team' => false,
|
||||
'show_boarding' => true,
|
||||
]);
|
||||
$user->teams()->attach($team, ['role' => 'owner']);
|
||||
|
||||
// User has 2 teams, 1 personal, 1 other where it is the owner and 1 other member is in the team
|
||||
$user = User::factory()->create([
|
||||
'name' => 'owner: 1 personal, 1 other team, owner, 1 other member',
|
||||
'email' => '2@example.com',
|
||||
]);
|
||||
$team = Team::create([
|
||||
'name' => '2@example.com',
|
||||
'personal_team' => false,
|
||||
'show_boarding' => true,
|
||||
]);
|
||||
$user->teams()->attach($team, ['role' => 'owner']);
|
||||
$user = User::factory()->create([
|
||||
'name' => 'member: 1 personal, 1 other team, owner, 1 other member',
|
||||
'email' => '3@example.com',
|
||||
]);
|
||||
$team->members()->attach($user, ['role' => 'member']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user