Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Chore/sync migration #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
fulleni merged 4 commits into main from chore/sync-migration
Oct 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions CHANGELOG.md
View file Open in desktop

This file was deleted.

View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import 'package:flutter_news_app_api_server_full_source_code/src/database/migration.dart';
import 'package:logging/logging.dart';
import 'package:mongo_dart/mongo_dart.dart';

/// Migration to add the `logoUrl` field to existing `sources` documents.
class AddLogoUrlToSources extends Migration {
/// {@macro add_logo_url_to_sources}
AddLogoUrlToSources()
: super(
prDate: '20251024000000',
prId: '60',
prSummary:
'Adds the required `logoUrl` field to all existing '
'documents in the `sources` collection to align with the '
'core v1.3.0 model update.',
);

@override
Future<void> up(Db db, Logger log) async {
final collection = db.collection('sources');
final sourcesToUpdate = await collection
.find(where.notExists('logoUrl'))
.toList();

if (sourcesToUpdate.isEmpty) {
log.info('No sources found needing a logoUrl. Migration is up to date.');
return;
}

log.info(
'Found ${sourcesToUpdate.length} sources to update with a logoUrl.',
);
var count = 0;
for (final source in sourcesToUpdate) {
final sourceUrl = source['url'] as String?;
if (sourceUrl != null && sourceUrl.isNotEmpty) {
try {
final host = Uri.parse(sourceUrl).host;
final logoUrl = 'https://logo.clearbit.com/$host?size=200';
await collection.updateOne(
where.id(source['_id'] as ObjectId),
modify.set('logoUrl', logoUrl),
);
count++;
} catch (e) {
log.warning(
'Could not parse URL for source ${source['_id']}: $sourceUrl',
);
}
}
}
log.info('Updated $count sources with a new logoUrl.');
}

@override
Future<void> down(Db db, Logger log) async {
final collection = db.collection('sources');
await collection.updateMany(
where.exists('logoUrl'),
modify.unset('logoUrl'),
);
log.info(
'Removed "logoUrl" field from all documents in the sources collection.',
);
}
}
2 changes: 2 additions & 0 deletions lib/src/database/migrations/all_migrations.dart
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter_news_app_api_server_full_source_code/src/database/migrat
import 'package:flutter_news_app_api_server_full_source_code/src/database/migrations/20250924084800__refactor_ad_config_to_role_based.dart';
import 'package:flutter_news_app_api_server_full_source_code/src/database/migrations/20251013000056_add_saved_filters_to_user_preferences.dart';
import 'package:flutter_news_app_api_server_full_source_code/src/database/migrations/20251013000057_add_saved_filters_to_remote_config.dart';
import 'package:flutter_news_app_api_server_full_source_code/src/database/migrations/20251024000000_add_logo_url_to_sources.dart';
import 'package:flutter_news_app_api_server_full_source_code/src/services/database_migration_service.dart'
show DatabaseMigrationService;

Expand All @@ -14,4 +15,5 @@ final List<Migration> allMigrations = [
RefactorAdConfigToRoleBased(),
AddSavedFiltersToUserPreferences(),
AddSavedFiltersToRemoteConfig(),
AddLogoUrlToSources(),
];
6 changes: 3 additions & 3 deletions pubspec.lock
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "v1.2.0"
resolved-ref: d052799c1ebb7bcdd1a725a2a7919948c14fa001
ref: "v1.3.0"
resolved-ref: ee2ad7de28baec04d64c0afd3e3a61d7e4ad6cb0
url: "https://github.com/flutter-news-app-full-source-code/core.git"
source: git
version: "1.2.0"
version: "1.3.0"
coverage:
dependency: transitive
description:
Expand Down
10 changes: 8 additions & 2 deletions pubspec.yaml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: flutter_news_app_api_server_full_source_code
description: The complete backend API server for the Flutter News App Toolkit, built with Dart Frog. Powers authentication, data management, user settings, and more.
repository: https://github.com/flutter-news-app-full-source-code/flutter-news-app-api-server-full-source-code
publish_to: none
version: 1.0.1
version: 1.1.0

environment:
sdk: ^3.9.0
Expand All @@ -12,7 +12,7 @@ dependencies:
core:
git:
url: https://github.com/flutter-news-app-full-source-code/core.git
ref: v1.2.0
ref: v1.3.0
dart_frog: ^1.1.0
dart_jsonwebtoken: ^3.2.0
data_client:
Expand Down Expand Up @@ -54,3 +54,9 @@ dev_dependencies:
mocktail: ^1.0.3
test: ^1.25.5
very_good_analysis: ^9.0.0

dependency_overrides:
core:
git:
url: https://github.com/flutter-news-app-full-source-code/core.git
ref: v1.3.0
Loading

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /