| 1: | <?php | 
| 2: |  | 
| 3: | use Afterlogic\DAV\Backend; | 
| 4: | use Illuminate\Database\Migrations\Migration; | 
| 5: | use Illuminate\Database\Capsule\Manager as Capsule; | 
| 6: |  | 
| 7: | class PopulateContactsCardsTable extends Migration | 
| 8: | { | 
| 9: |  | 
| 10: |  | 
| 11: |  | 
| 12: |  | 
| 13: |  | 
| 14: | public function up() | 
| 15: | { | 
| 16: | Capsule::connection()->table('adav_cards')->orderBy('id')->chunk(100000, function ($rows) { | 
| 17: | foreach ($rows as $row) { | 
| 18: | try { | 
| 19: | Backend::Carddav()->updateProperties($row->addressbookid, $row->uri, $row->carddata); | 
| 20: | } catch (\Exception $e) { | 
| 21: | \Aurora\System\Api::Log('Contact migration exception', \Aurora\System\Enums\LogLevel::Error, 'contacts-migration-'); | 
| 22: | \Aurora\System\Api::LogObject($row, \Aurora\System\Enums\LogLevel::Error, 'contacts-migration-'); | 
| 23: | \Aurora\System\Api::Log($e->getMessage(), \Aurora\System\Enums\LogLevel::Error, 'contacts-migration-'); | 
| 24: |  | 
| 25: | } | 
| 26: | } | 
| 27: | }); | 
| 28: | } | 
| 29: |  | 
| 30: |  | 
| 31: |  | 
| 32: |  | 
| 33: |  | 
| 34: |  | 
| 35: | public function down() {} | 
| 36: | } | 
| 37: |  |