executeImpl method
Implement the actual tool logic
params are the validated parameters (never null here)
Returns the result data to send in the response
Implementation
@override
Future<dynamic> executeImpl(Map<String, dynamic> params) async {
final tableFilter = params['table_filter'] as String?;
final includeContent = params['include_content'] as bool? ?? false;
final project = ServerPodLocator.getProject();
if (project == null || !project.isValid) {
return {'error': 'Not a valid ServerPod project'};
}
final migrationFiles = project.migrationFiles;
final results = <Map<String, dynamic>>[];
for (final file in migrationFiles) {
final filename = p.basename(file.path);
final tableName = _extractTableName(filename);
// Apply filter if provided
if (tableFilter != null &&
tableName != null &&
!tableName.toLowerCase().contains(tableFilter.toLowerCase())) {
continue;
}
final stat = file.statSync();
final content = includeContent ? await file.readAsString() : null;
results.add({
'filename': filename,
'path': file.path,
'table': tableName,
'modified': stat.modified.toIso8601String(),
'size': stat.size,
if (content != null) 'content': content,
});
}
return {
'migrations': results,
'count': results.length,
'migrationsPath': project.migrationsPath,
};
}