Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@
"scripts": {
"dev": [
"Composer\\Config::disableProcessTimeout",
"cd ../bundle && npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev --prefix ../framework/packages/ui\" --names=server,queue,logs,vite --kill-others"
"cd ../froxlor && npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev --prefix ../framework/packages/ui\" --names=server,queue,logs,vite --kill-others"
],
"dev:assets": [
"rm -f ../bundle/public/vendor/froxlor/ui && ln -s ../../../../framework/packages/ui/dist ../bundle/public/vendor/froxlor/ui && echo 'Linked assets for development.'"
"mkdir -p ../froxlor/public/vendor/froxlor && if [ -e ../froxlor/public/vendor/froxlor/ui ] || [ -L ../froxlor/public/vendor/froxlor/ui ]; then rm -rf ../froxlor/public/vendor/froxlor/ui; fi && ln -s ../../../../framework/packages/ui/dist ../froxlor/public/vendor/froxlor/ui && echo 'Linked UI assets for development.'"
],
"assets:publish": [
"cd ../froxlor && php artisan vendor:publish --tag=froxlor-ui-assets --ansi --force"
]
},
"replace": {
Expand Down
Original file line number Diff line number Diff line change
@@ -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::table('tenants', function (Blueprint $table) {
$table->foreign('parent_tenant_id')
->references('id')
->on('tenants')
->restrictOnDelete();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('tenants', function (Blueprint $table) {
$table->dropForeign(['parent_tenant_id']);
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;

return new class extends Migration
{
public function up(): void
{
Schema::table('settings', function (Blueprint $table): void {
$table->string('owner_package', 191)->nullable()->after('key');
$table->string('definition_key', 26)->nullable()->after('owner_package');
$table->index('owner_package');
$table->index('definition_key');
});

// Existing rows are grouped into stable definitions before ownership is backfilled.
// Rows whose original package cannot be determined remain explicitly unowned and must
// be adopted by a deliberate package migration before their definition can change.
DB::table('settings')
->select('category', 'key')
->distinct()
->get()
->each(function (object $path): void {
$definitionKey = DB::table('settings')
->where('category', $path->category)
->where('key', $path->key)
->whereNotNull('definition_key')
->value('definition_key')
?? (string)Str::ulid();

DB::table('settings')
->where('category', $path->category)
->where('key', $path->key)
->update(['definition_key' => $definitionKey]);
});

$knownOwners = [
'auditlog' => 'froxlor/core',
'api' => 'froxlor/core',
'core' => 'froxlor/core',
'node' => 'froxlor/core',
'appearance' => 'froxlor/ui',
];

foreach ($knownOwners as $category => $owner) {
DB::table('settings')
->where('category', $category)
->whereNull('owner_package')
->update(['owner_package' => $owner]);
}

DB::table('settings')
->where('category', 'packages')
->whereNull('owner_package')
->get(['id', 'key'])
->each(function (object $setting): void {
$owner = match ($setting->key) {
'marketplace_username', 'marketplace_token' => 'froxlor/packages',
default => null,
};

if ($owner === null && preg_match('/^(.+)\.(enabled|pending)$/', $setting->key, $matches)) {
$owner = $matches[1];
}

if ($owner !== null) {
DB::table('settings')
->where('id', $setting->id)
->update(['owner_package' => $owner]);
}
});
}

public function down(): void
{
Schema::table('settings', function (Blueprint $table): void {
$table->dropIndex('settings_owner_package_index');
$table->dropIndex('settings_definition_key_index');
$table->dropColumn(['owner_package', 'definition_key']);
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?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('nodes', function (Blueprint $table): void {
$table->string('setup_status', 16)->nullable();
$table->ulid('setup_request_id')->nullable();
// Retain the actor ID for diagnosis even if the user is subsequently deleted.
$table->ulid('setup_requested_by')->nullable();
$table->json('setup_selection')->nullable();
$table->char('setup_fingerprint', 64)->nullable();
$table->ulid('setup_run_id')->nullable();
$table->timestamp('setup_requested_at')->nullable();
$table->timestamp('setup_started_at')->nullable();
$table->timestamp('setup_finished_at')->nullable();
$table->string('setup_error')->nullable();
});
}

public function down(): void
{
Schema::table('nodes', function (Blueprint $table): void {
$table->dropColumn([
'setup_status', 'setup_request_id', 'setup_requested_by', 'setup_selection',
'setup_fingerprint', 'setup_run_id', 'setup_requested_at', 'setup_started_at',
'setup_finished_at', 'setup_error',
]);
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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
{
public function up(): void
{
foreach (['tenant_user', 'environment_user'] as $table) {
Schema::table($table, function (Blueprint $table): void {
$table->ulid('role_id')->nullable()->change();
});
}
}

public function down(): void
{
// Never invent permissions or remove memberships to satisfy a rollback.
foreach (['tenant_user', 'environment_user'] as $table) {
if (DB::table($table)->whereNull('role_id')->exists()) {
throw new RuntimeException('Assign roles to roleless memberships before rolling back this migration.');
}
}
foreach (['tenant_user', 'environment_user'] as $table) {
Schema::table($table, function (Blueprint $table): void {
$table->ulid('role_id')->nullable(false)->change();
});
}
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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
{
public function up(): void
{
Schema::create('quota_locks', function (Blueprint $table): void {
$table->unsignedTinyInteger('id')->primary();
});
DB::table('quota_locks')->insert(['id' => 1]);
}

public function down(): void
{
Schema::dropIfExists('quota_locks');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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('node_environments', function (Blueprint $table): void {
$table->string('jail_path')->nullable();
$table->json('jail_manifest')->nullable();
});
}

public function down(): void
{
Schema::table('node_environments', fn (Blueprint $table) => $table->dropColumn(['jail_path', 'jail_manifest']));
}
};
Original file line number Diff line number Diff line change
@@ -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('nodes', function (Blueprint $table): void {
$table->json('setup_services')->nullable();
});
}

public function down(): void
{
Schema::table('nodes', function (Blueprint $table): void {
$table->dropColumn('setup_services');
});
}
};
2 changes: 1 addition & 1 deletion packages/core/database/seeders/SettingsTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SettingsTableSeeder extends Seeder
public function run(): void
{
foreach ($this->settings as $setting) {
Setting::addFromArray($setting);
Setting::addFromArray($setting, source: 'froxlor/core');
}
}
}
2 changes: 1 addition & 1 deletion packages/core/database/seeders/Testing/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
Setting::set('auditlog.severity', 7, 'integer', 5);
Setting::set('auditlog.severity', 7, 'integer', 5, 'froxlor/core');

$this->call([
PlansAndResourcesTableSeeder::class,
Expand Down
Loading
Loading