Skip to content

Commit

Permalink
Set last_activity_id for each user
Browse files Browse the repository at this point in the history
  • Loading branch information
alexweissman committed Dec 2, 2017
1 parent 4a5d042 commit cc6bc44
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Bakery/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Symfony\Component\Console\Input\InputOption;
use UserFrosting\Sprinkle\Account\Database\Models\Permission;
use UserFrosting\Sprinkle\Account\Database\Models\Role;
use UserFrosting\Sprinkle\Account\Database\Models\User;
use UserFrosting\System\Bakery\BaseCommand;
use UserFrosting\System\Bakery\DatabaseTest;

Expand Down Expand Up @@ -289,7 +290,7 @@ protected function migrateUsers($tableName)
]);
}

// TODO: set theme, last_activity_id for each user
// TODO: set theme for each user
}

protected function migrateUserRoles($tableName)
Expand Down Expand Up @@ -320,6 +321,15 @@ protected function migrateActivities($tableName)
'description' => $legacyRow->description
]);
}

// Set last_activity_id for each user
$newUsers = User::with('lastActivityOfType')->get();
foreach ($newUsers as $user) {
if ($user->lastActivityOfType) {
$user->last_activity_id = $user->lastActivityOfType->id;
$user->save();
}
}
}

protected function reAddDefaultRolesAndPermissions()
Expand Down

0 comments on commit cc6bc44

Please sign in to comment.