update files script

This commit is contained in:
2024-09-27 16:27:37 +03:00
parent 6458c1e71d
commit 19931cb4d1
4 changed files with 34 additions and 6 deletions
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace Lucent\Commands;
use Illuminate\Console\Command;
use Lucent\Database\Database;
class UpgradeFiles122 extends Command
{
protected $signature = 'lucent:upgrade:files_1_2_2 {schema} {disk}';
protected $description = 'Upgrade to the new filesystem';
public function handle()
{
$schema = $this->argument('schema');
$disk = $this->argument('disk');
$db = Database::make();
$records = $db->table("records")->where("schema", $schema)->get();
foreach ($records as $record) {
$array = json_decode($record->_file, true);
$array["disk"] = $disk;
$db->table("records")->where("id", $record->id)->update(["_file" => json_encode($array)]);
}
}
}
+2
View File
@@ -15,6 +15,7 @@ use Lucent\Commands\LiveLink;
use Lucent\Commands\RebuildThumbnails;
use Lucent\Commands\RemoveOrphanEdges;
use Lucent\Commands\SetupDatabase;
use Lucent\Commands\UpgradeFiles122;
use Lucent\File\FileService;
use Lucent\File\ImageService;
use Lucent\Query\DatabaseGraph\DatabaseGraph;
@@ -79,6 +80,7 @@ class LucentServiceProvider extends ServiceProvider
SetupDatabase::class,
GenerateCollectionSchema::class,
GenerateFileSchema::class,
UpgradeFiles122::class,
]);
}
+1 -1
View File
@@ -36,7 +36,7 @@ class SchemaService
name: $schemaArr["name"],
label: $schemaArr["label"],
fields: (new Collection($schemaArr["fields"]))->map([$this, 'mapFields']),
disk: $schemaArr["disk"],
disk: $schemaArr["disk"] ?? "lucent",
path: $schemaArr["path"] ?? $schemaArr["name"],
groups: $schemaArr["groups"] ?? [],
isEntry: $schemaArr["isEntry"] ?? false,