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

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