#111: Added the migration SQL to populate the user_activity table
This commit is contained in:
parent
80a7824f22
commit
54e327ee9e
@ -12,6 +12,32 @@ class DataMigrationV2_2_0_alpha_1 extends DataMigration
|
||||
|
||||
public function run($currentVersion)
|
||||
{
|
||||
//DB::insert('INSERT INTO user_activity ()')
|
||||
// Insert photo.uploaded events
|
||||
DB::insert('INSERT INTO user_activity (user_id, activity_at, type, photo_id, created_at, updated_at)
|
||||
SELECT photos.user_id, photos.created_at, \'photo.uploaded\', photos.id, NOW(), NOW()
|
||||
FROM photos
|
||||
LEFT OUTER JOIN user_activity ON (user_activity.user_id = photos.user_id AND user_activity.activity_at = photos.created_at AND user_activity.type = \'photo.uploaded\' AND user_activity.photo_id = photos.id)
|
||||
WHERE user_activity.id IS NULL');
|
||||
|
||||
// Insert photo.taken events
|
||||
DB::insert('INSERT INTO user_activity (user_id, activity_at, type, photo_id, created_at, updated_at)
|
||||
SELECT photos.user_id, photos.taken_at, \'photo.taken\', photos.id, NOW(), NOW()
|
||||
FROM photos
|
||||
LEFT OUTER JOIN user_activity ON (user_activity.user_id = photos.user_id AND user_activity.activity_at = photos.taken_at AND user_activity.type = \'photo.taken\' AND user_activity.photo_id = photos.id)
|
||||
WHERE user_activity.id IS NULL AND photos.taken_at IS NOT NULL');
|
||||
|
||||
// Insert album.created events
|
||||
DB::insert('INSERT INTO user_activity (user_id, activity_at, type, album_id, created_at, updated_at)
|
||||
SELECT albums.user_id, albums.created_at, \'album.created\', albums.id, NOW(), NOW()
|
||||
FROM albums
|
||||
LEFT OUTER JOIN user_activity ON (user_activity.user_id = albums.user_id AND user_activity.activity_at = albums.created_at AND user_activity.type = \'album.created\' AND user_activity.album_id = albums.id)
|
||||
WHERE user_activity.id IS NULL');
|
||||
|
||||
// Insert user.created events
|
||||
DB::insert('INSERT INTO user_activity (user_id, activity_at, type, created_at, updated_at)
|
||||
SELECT users.id, users.created_at, \'user.created\', NOW(), NOW()
|
||||
FROM users
|
||||
LEFT OUTER JOIN user_activity ON (user_activity.user_id = users.id AND user_activity.activity_at = users.created_at AND user_activity.type = \'user.created\')
|
||||
WHERE user_activity.id IS NULL');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user