added auto_inc to id in styles table

fixed a bug in the ai-model edit form
switched to sqlite
This commit is contained in:
2025-08-06 13:39:36 +02:00
parent 57f3dbc402
commit 573661825b
6 changed files with 48 additions and 82 deletions

View File

@@ -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),
]);
}

View File

@@ -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'),

View File

@@ -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');

View File

@@ -1,29 +0,0 @@
<?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('ai_models', function (Blueprint $table) {
$table->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.
});
}
};

View File

@@ -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');
});

View File

@@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::rename('settings', 'settings_old');
Schema::create('settings', function (Blueprint $table) {
$table->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();
});
}
};