diff --git a/app/Console/Commands/ConvertImageHashTable.php b/app/Console/Commands/ConvertImageHashTable.php deleted file mode 100644 index 37799356..00000000 --- a/app/Console/Commands/ConvertImageHashTable.php +++ /dev/null @@ -1,73 +0,0 @@ -error('Does not work with sqlite.'); - - return 1; - } - - Schema::dropIfExists('comm_link_image_hashes_temp'); - Schema::create('comm_link_image_hashes_temp', static function (Blueprint $table) { - $table->id(); - $table->unsignedInteger('comm_link_image_id'); - $table->binary('average_hash'); - $table->binary('perceptual_hash'); - $table->binary('difference_hash'); - $table->timestamps(); - - $table->foreign('comm_link_image_id')->references('id')->on('comm_link_images')->onDelete('cascade'); - $table->unique('comm_link_image_id'); - }); - - $select = ImageHash::query() - ->select(['comm_link_image_id']) - ->selectRaw('CAST(CONV(perceptual_hash, 16, 10) AS UNSIGNED INTEGER) as perceptual_hash') - ->selectRaw('CAST(CONV(average_hash, 16, 10) AS UNSIGNED INTEGER) as average_hash') - ->selectRaw('CAST(CONV(difference_hash, 16, 10) AS UNSIGNED INTEGER) as difference_hash') - ->selectRaw('created_at') - ->selectRaw('updated_at'); - - DB::table('comm_link_image_hashes_temp')->insertUsing([ - 'comm_link_image_id', - 'perceptual_hash', - 'average_hash', - 'difference_hash', - 'created_at', - 'updated_at', - ], $select); - - Schema::rename('comm_link_image_hashes', 'comm_link_image_hashes_old'); - Schema::rename('comm_link_image_hashes_temp', 'comm_link_image_hashes'); - - return 0; - } -} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index dcaec052..24ef3702 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -139,8 +139,6 @@ class Kernel extends ConsoleKernel PopulateData::class, CopyTranslationData::class, - - ConvertImageHashTable::class, ]; /** diff --git a/database/migrations/update/rsi/comm_link/image/2023_12_23_194807_add_pdq_hash_to_comm_link_image_hashes_table.php b/database/migrations/update/rsi/comm_link/image/2023_12_23_194807_add_pdq_hash_to_comm_link_image_hashes_table.php index 71dab7a9..76cb86f7 100644 --- a/database/migrations/update/rsi/comm_link/image/2023_12_23_194807_add_pdq_hash_to_comm_link_image_hashes_table.php +++ b/database/migrations/update/rsi/comm_link/image/2023_12_23_194807_add_pdq_hash_to_comm_link_image_hashes_table.php @@ -11,12 +11,22 @@ */ public function up(): void { - Schema::table('comm_link_image_hashes', static function (Blueprint $table) { - $table->binary('pdq_hash1')->nullable()->after('difference_hash'); - $table->binary('pdq_hash2')->nullable()->after('pdq_hash1'); - $table->binary('pdq_hash3')->nullable()->after('pdq_hash2'); - $table->binary('pdq_hash4')->nullable()->after('pdq_hash3'); - $table->smallInteger('pdq_quality')->nullable()->after('pdq_hash4'); + Schema::dropIfExists('comm_link_image_hashes'); + Schema::create('comm_link_image_hashes', static function (Blueprint $table) { + $table->id(); + $table->unsignedInteger('comm_link_image_id'); + $table->binary('average_hash'); + $table->binary('perceptual_hash'); + $table->binary('difference_hash'); + $table->binary('pdq_hash1'); + $table->binary('pdq_hash2'); + $table->binary('pdq_hash3'); + $table->binary('pdq_hash4'); + $table->smallInteger('pdq_quality'); + $table->timestamps(); + + $table->foreign('comm_link_image_id')->references('id')->on('comm_link_images')->onDelete('cascade'); + $table->unique('comm_link_image_id'); }); } @@ -25,12 +35,17 @@ public function up(): void */ public function down(): void { - Schema::table('comm_link_image_hashes', static function (Blueprint $table) { - $table->dropColumn('pdq_hash1'); - $table->dropColumn('pdq_hash2'); - $table->dropColumn('pdq_hash3'); - $table->dropColumn('pdq_hash4'); - $table->dropColumn('pdq_quality'); + Schema::dropIfExists('comm_link_image_hashes'); + Schema::create('comm_link_image_hashes', static function (Blueprint $table) { + $table->id(); + $table->unsignedInteger('comm_link_image_id'); + $table->binary('average_hash'); + $table->binary('perceptual_hash'); + $table->binary('difference_hash'); + $table->timestamps(); + + $table->foreign('comm_link_image_id')->references('id')->on('comm_link_images')->onDelete('cascade'); + $table->unique('comm_link_image_id'); }); } };