From 573661825bdeb21d4222e49a1f928509b372bba0 Mon Sep 17 00:00:00 2001 From: SEB Fotografie - soeren Date: Wed, 6 Aug 2025 13:39:36 +0200 Subject: [PATCH] added auto_inc to id in styles table fixed a bug in the ai-model edit form switched to sqlite --- app/Filament/Resources/AiModelResource.php | 3 +- config/database.php | 49 ------------------- .../2025_07_24_165805_create_styles_table.php | 2 +- ...rovider_id_nullable_in_ai_models_table.php | 29 ----------- ...d_style_change_columns_to_images_table.php | 2 +- ..._08_06_105716_add_id_to_settings_table.php | 45 +++++++++++++++++ 6 files changed, 48 insertions(+), 82 deletions(-) delete mode 100644 database/migrations/2025_07_28_175654_make_api_provider_id_nullable_in_ai_models_table.php create mode 100644 database/migrations/2025_08_06_105716_add_id_to_settings_table.php diff --git a/app/Filament/Resources/AiModelResource.php b/app/Filament/Resources/AiModelResource.php index faf5c55..3e803d1 100644 --- a/app/Filament/Resources/AiModelResource.php +++ b/app/Filament/Resources/AiModelResource.php @@ -51,9 +51,8 @@ class AiModelResource extends Resource ->label(__('filament.resource.ai_model.form.parameters')) ->nullable() ->rows(15) - ->json() + ->json(JSON_PRETTY_PRINT) ->helperText(__('filament.resource.ai_model.form.parameters_help')) - ->formatStateUsing(fn (?array $state): ?string => $state ? json_encode($state, JSON_PRETTY_PRINT) : null), ]); } diff --git a/config/database.php b/config/database.php index 137ad18..c041e83 100644 --- a/config/database.php +++ b/config/database.php @@ -4,35 +4,8 @@ use Illuminate\Support\Str; return [ - /* - |-------------------------------------------------------------------------- - | Default Database Connection Name - |-------------------------------------------------------------------------- - | - | Here you may specify which of the database connections below you wish - | to use as your default connection for all database work. Of course - | you may use many connections at once using the Database library. - | - */ - 'default' => env('DB_CONNECTION', 'mysql'), - /* - |-------------------------------------------------------------------------- - | Database Connections - |-------------------------------------------------------------------------- - | - | Here are each of the database connections setup for your application. - | Of course, examples of configuring each database platform that is - | supported by Laravel is shown below to make development simple. - | - | - | All database work in Laravel is done through the PHP PDO facilities - | so make sure you have the driver for your particular database of - | choice installed on your machine before you begin development. - | - */ - 'connections' => [ 'sqlite' => [ @@ -95,30 +68,8 @@ return [ ], - /* - |-------------------------------------------------------------------------- - | Migration Repository Table - |-------------------------------------------------------------------------- - | - | This table keeps track of all the migrations that have already run for - | your application. Using this information, we can determine which of - | the migrations on disk haven't actually been run in the database. - | - */ - 'migrations' => 'migrations', - /* - |-------------------------------------------------------------------------- - | Redis Databases - |-------------------------------------------------------------------------- - | - | Redis is an open source, fast, and advanced key-value store that also - | provides a richer body of commands than a typical key-value system - | such as APC or Memcached. Laravel makes it easy to dig right in. - | - */ - 'redis' => [ 'client' => env('REDIS_CLIENT', 'phpredis'), diff --git a/database/migrations/2025_07_24_165805_create_styles_table.php b/database/migrations/2025_07_24_165805_create_styles_table.php index 4cf02a6..e90d405 100644 --- a/database/migrations/2025_07_24_165805_create_styles_table.php +++ b/database/migrations/2025_07_24_165805_create_styles_table.php @@ -12,7 +12,7 @@ return new class extends Migration public function up(): void { Schema::create('styles', function (Blueprint $table) { - $table->id(); + $table->increments('id'); $table->string('title'); $table->text('prompt'); $table->text('description'); diff --git a/database/migrations/2025_07_28_175654_make_api_provider_id_nullable_in_ai_models_table.php b/database/migrations/2025_07_28_175654_make_api_provider_id_nullable_in_ai_models_table.php deleted file mode 100644 index 8edded3..0000000 --- a/database/migrations/2025_07_28_175654_make_api_provider_id_nullable_in_ai_models_table.php +++ /dev/null @@ -1,29 +0,0 @@ -foreignId('api_provider_id')->nullable()->change(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('ai_models', function (Blueprint $table) { - // If you want to revert, you might need to make it non-nullable again - // or handle existing null values. For simplicity, we'll leave it as is. - }); - } -}; \ No newline at end of file diff --git a/database/migrations/2025_07_30_201035_add_style_change_columns_to_images_table.php b/database/migrations/2025_07_30_201035_add_style_change_columns_to_images_table.php index feb8648..2e09fc4 100644 --- a/database/migrations/2025_07_30_201035_add_style_change_columns_to_images_table.php +++ b/database/migrations/2025_07_30_201035_add_style_change_columns_to_images_table.php @@ -14,7 +14,7 @@ return new class extends Migration Schema::table('images', function (Blueprint $table) { $table->unsignedBigInteger('original_image_id')->nullable()->after('id'); $table->foreign('original_image_id')->references('id')->on('images')->onDelete('set null'); - $table->unsignedBigInteger('style_id')->nullable()->after('original_image_id'); + $table->unsignedInteger('style_id')->nullable()->after('original_image_id'); $table->foreign('style_id')->references('id')->on('styles')->onDelete('set null'); $table->boolean('is_temp')->default(false)->after('style_id'); }); diff --git a/database/migrations/2025_08_06_105716_add_id_to_settings_table.php b/database/migrations/2025_08_06_105716_add_id_to_settings_table.php new file mode 100644 index 0000000..28c33e0 --- /dev/null +++ b/database/migrations/2025_08_06_105716_add_id_to_settings_table.php @@ -0,0 +1,45 @@ +id(); + $table->string('key')->unique(); + $table->text('value')->nullable(); + $table->timestamps(); + }); + + $oldSettings = DB::table('settings_old')->get(); + foreach ($oldSettings as $setting) { + DB::table('settings')->insert((array)$setting); + } + + Schema::drop('settings_old'); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('settings'); + + Schema::create('settings', function (Blueprint $table) { + $table->string('key')->primary(); + $table->text('value')->nullable(); + $table->timestamps(); + }); + } +}; \ No newline at end of file