diff --git a/database/migrations/2024_04_10_091519_create_standalone_clickhouses_table.php b/database/migrations/2024_04_10_091519_create_standalone_clickhouses_table.php index f7ea310cf..7433948b9 100644 --- a/database/migrations/2024_04_10_091519_create_standalone_clickhouses_table.php +++ b/database/migrations/2024_04_10_091519_create_standalone_clickhouses_table.php @@ -19,7 +19,6 @@ public function up(): void $table->string('clickhouse_admin_user')->default('default'); $table->text('clickhouse_admin_password'); - $table->string('clickhouse_db')->default('default'); $table->boolean('is_log_drain_enabled')->default(false); $table->boolean('is_include_timestamps')->default(false); @@ -27,7 +26,7 @@ public function up(): void $table->string('status')->default('exited'); - $table->string('image')->default('clickhouse/clickhouse-server:latest'); + $table->string('image')->default('bitnami/clickhouse'); $table->boolean('is_public')->default(false); $table->integer('public_port')->nullable(); diff --git a/database/migrations/2025_10_03_154100_update_clickhouse_image.php b/database/migrations/2025_10_03_154100_update_clickhouse_image.php new file mode 100644 index 000000000..e57354037 --- /dev/null +++ b/database/migrations/2025_10_03_154100_update_clickhouse_image.php @@ -0,0 +1,32 @@ +string('image')->default('bitnamilegacy/clickhouse')->change(); + }); + // Optionally, update any existing rows with the old default to the new one + DB::table('standalone_clickhouses') + ->where('image', 'bitnami/clickhouse') + ->update(['image' => 'bitnamilegacy/clickhouse']); + } + + public function down() + { + Schema::table('standalone_clickhouses', function (Blueprint $table) { + $table->string('image')->default('bitnami/clickhouse')->change(); + }); + // Optionally, revert any changed values + DB::table('standalone_clickhouses') + ->where('image', 'bitnamilegacy/clickhouse') + ->update(['image' => 'bitnami/clickhouse']); + } +}; diff --git a/database/migrations/2025_11_28_000001_migrate_clickhouse_to_official_image.php b/database/migrations/2025_11_28_000001_migrate_clickhouse_to_official_image.php index 925b0dd09..4e8528c12 100644 --- a/database/migrations/2025_11_28_000001_migrate_clickhouse_to_official_image.php +++ b/database/migrations/2025_11_28_000001_migrate_clickhouse_to_official_image.php @@ -1,11 +1,11 @@ string('clickhouse_db') ->default('default') ->after('clickhouse_admin_password'); }); } + + // Change the default value for the 'image' column to the official image + Schema::table('standalone_clickhouses', function (Blueprint $table) { + $table->string('image')->default('clickhouse/clickhouse-server:latest')->change(); + }); + + // Update existing ClickHouse instances from Bitnami images to official image StandaloneClickhouse::where(function ($query) { - $query->where('image', 'like', '%bitnami/clickhouse%') - ->orWhere('image', 'like', '%bitnamilegacy/clickhouse%'); - }) + $query->where('image', 'like', '%bitnami/clickhouse%') + ->orWhere('image', 'like', '%bitnamilegacy/clickhouse%'); + }) ->update([ 'image' => 'clickhouse/clickhouse-server:latest', - 'clickhouse_db' => DB::raw("COALESCE(clickhouse_db, 'default')") + 'clickhouse_db' => DB::raw("COALESCE(clickhouse_db, 'default')"), ]); + // Update volume mount paths from Bitnami to official image paths LocalPersistentVolume::where('resource_type', StandaloneClickhouse::class) ->where('mount_path', '/bitnami/clickhouse') ->update(['mount_path' => '/var/lib/clickhouse']); @@ -43,8 +52,16 @@ public function up(): void */ public function down(): void { + // Revert the default value for the 'image' column + Schema::table('standalone_clickhouses', function (Blueprint $table) { + $table->string('image')->default('bitnamilegacy/clickhouse')->change(); + }); + + // Revert existing ClickHouse instances back to Bitnami image StandaloneClickhouse::where('image', 'clickhouse/clickhouse-server:latest') - ->update(['image' => 'bitnami/clickhouse']); + ->update(['image' => 'bitnamilegacy/clickhouse']); + + // Revert volume mount paths LocalPersistentVolume::where('resource_type', StandaloneClickhouse::class) ->where('mount_path', '/var/lib/clickhouse') ->update(['mount_path' => '/bitnami/clickhouse']);