Skip to content

feat: migrate image storage from image_url field to world_heritage_site_images table#396

Merged
zigzagdev merged 20 commits intomainfrom
chore/integrate-image_url-into-image-table
Mar 29, 2026
Merged

feat: migrate image storage from image_url field to world_heritage_site_images table#396
zigzagdev merged 20 commits intomainfrom
chore/integrate-image_url-into-image-table

Conversation

@zigzagdev
Copy link
Copy Markdown
Owner

Summary

Images are now stored exclusively in world_heritage_site_images table
instead of world_heritage_sites.image_url / primary_image_url.

Changes

Verification

  • php artisan app:world-heritage-build --fresh --jp --pretty --clear --algolia --algolia-truncate
  • All 1248 records processed
  • Images correctly stored in world_heritage_site_images
  • Detail API returns images array with correct shape

…mage_url-into-heritage-command

chore: world_heritage-split-command-refactor
…est-fix

test: add image contract tests for getHeritageById
…-command

chore: remove runtime usage of image_url from commands and query services
chore: drop image_url column from world_heritage_sites
fix: fix image url key in split JSON and cleanup image_url references
Copy link
Copy Markdown
Owner Author

@zigzagdev zigzagdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates world-heritage image handling away from legacy world_heritage_sites.image_url / primary_image_url columns and toward the world_heritage_site_images table, updating query paths, importer/normalizer behavior, and related tests/seed data.

Changes:

  • Drops legacy image_url / primary_image_url columns and removes seeder/test data that still referenced them.
  • Updates query/services and Algolia indexing to derive thumbnail/primary image from world_heritage_site_images.
  • Adjusts detail-query tests to validate the images array contract.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/database/seeders/WorldHeritageSeeder.php Removes legacy image_url seed field.
src/database/migrations/2026_03_29_155722_drop_primary_image_url_from_world_heritage_sites.php Drops primary_image_url column.
src/database/migrations/2026_03_29_151147_drop_image_url_from_world_heritage_sites.php Drops image_url column.
src/app/Packages/Features/QueryUseCases/QueryServiceInterface/WorldHeritageQueryServiceInterface.php Removes getHeritagesByIds() from the query service interface.
src/app/Packages/Domains/WorldHeritageReadQueryService.php Uses primary image relation; used by Algolia search result hydration.
src/app/Packages/Domains/WorldHeritageQueryService.php Switches list payload thumbnail source to images table; removes getHeritagesByIds() implementation; adjusts image DTO mapping.
src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_getByIdTest.php Adds/updates tests for images array contract and empty behavior.
src/app/Packages/Domains/Test/QueryService/WorldHeritageQueryService_countEachRegionTest.php Removes legacy image_url from test record seed.
src/app/Models/WorldHeritage.php Removes thumbnail relation/fillable related to legacy thumbnail setup.
src/app/Models/Image.php Aligns Image model to world_heritage_site_images table usage and adds casting.
src/app/Models/Country.php Removes an unused import.
src/app/Console/Commands/SplitWorldHeritageJson.php Stops emitting legacy image fields; refactors URL extraction/deduplication.
src/app/Console/Commands/ImportWorldHeritageSiteFromSplitFile.php Stops writing legacy image_url on site import.
src/app/Console/Commands/AlgoliaImportWorldHeritages.php Loads primary image via relation for Algolia thumbnail_url.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +25 to +30
public function casts(): array
{
return [
'is_primary' => 'boolean',
];
}
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with other models in this codebase (e.g. WorldHeritage), consider declaring this as protected function casts(): array (or using a $casts property). While increasing visibility works in PHP, keeping it consistent helps tooling and readability.

Copilot uses AI. Check for mistakes.
@@ -33,13 +33,15 @@ public function findByIdsPreserveOrder(array $ids): Collection
'world_heritage_sites.latitude',
'world_heritage_sites.longitude',
'world_heritage_sites.short_description',
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findByIdsPreserveOrder() feeds models into buildWorldHeritagePayload(), which includes unesco_site_url. Because this select list omits world_heritage_sites.unesco_site_url, search results built from these models will always return unesco_site_url as null. Include world_heritage_sites.unesco_site_url in the selected columns (or stop emitting it from the payload for this path).

Suggested change
'world_heritage_sites.short_description',
'world_heritage_sites.short_description',
'world_heritage_sites.unesco_site_url',

Copilot uses AI. Check for mistakes.
Comment on lines 28 to 33
public function getAllHeritages(
int $currentPage,
int $perPage,
string $order
): PaginationDto
{
): PaginationDto {
$items = WorldHeritage::query()
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method signature puts the opening brace on the same line as the return type, while the rest of the class uses the brace on the next line. Since the repo uses Laravel Pint, this will likely be reformatted anyway; consider keeping it consistent (PSR-12 style) to avoid noisy diffs.

Copilot uses AI. Check for mistakes.
Comment on lines +102 to +103
array $extra =
[]
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value for $extra is split across lines (array $extra = then []). This is valid PHP but inconsistent with the surrounding formatting and will likely be rewritten by Pint; please format it as a single parameter line (array $extra = []) or use a standard multiline style.

Suggested change
array $extra =
[]
array $extra = []

Copilot uses AI. Check for mistakes.
public function up(): void
{
Schema::table('world_heritage_sites', function (Blueprint $table) {
$table->dropColumn('primary_image_url');
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation inside the Schema::table callback is inconsistent here (the dropped column line is over-indented and the closing brace is misaligned). Please reformat to the standard indentation to keep migrations consistent and avoid Pint reformat churn.

Suggested change
$table->dropColumn('primary_image_url');
$table->dropColumn('primary_image_url');

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zigzagdev zigzagdev merged commit 83101e9 into main Mar 29, 2026
28 checks passed
@zigzagdev zigzagdev deleted the chore/integrate-image_url-into-image-table branch March 29, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug[🐛]: Fix UNESCO image import: store only images in world_heritage_site_images with stable ordering (no image_url writes)

2 participants