Last Import stuck in iPhoto Events folder after migrating to Photos app
I created a fresh new iPhoto library, populated it with some photos, and migrated that library to Photos, but I could not reproduce this problem. So it looks like another problem with my original iPhoto library. Great.

So I decided to look directly in the Photos library database to see what was going on. The Photos library database can be found in ~/Pictures/Photos Library.photoslibrary/Database/Library.apdb; this is an SQLite database that can be opened using the command-line sqlite3 tool, or any GUI you prefer.

If you're about to follow the steps in my answer past this point, remember to back up the library file before proceeding.

The schema for RKAlbum contains a folderUuid column that associates an album with a folder (in RKFolder). In the Photos library that was migrated from the fresh iPhoto library, the Last Import album looks like this:

sqlite&gt; SELECT name, folderUuid FROM RKAlbum WHERE name = 'Last Import';
Last Import|LibraryFolder


But in the Photos library that was created from my original iPhoto library, the album looks like this:

sqlite&gt; SELECT name, folderUuid FROM RKAlbum WHERE name = 'Last Import';
Last Import|cQeJj7YPRmSxHysWN+ql4w


Notice that folderUuid here is a generated string and not 'LibraryFolder'. Obviously, this is an arbitrary folder — specifically the iPhoto Events folder that is created as part of the migration process. And sure enough:

sqlite&gt; SELECT uuid, name FROM RKFolder WHERE uuid = 'cQeJj7YPRmSxHysWN+ql4w';
cQeJj7YPRmSxHysWN+ql4w|iPhoto Events


As an immediate workaround, changing the column directly seems to work:

sqlite&gt; UPDATE RKAlbum SET folderUuid = 'LibraryFolder' WHERE name = 'Last Import';


Now opening Photos and deleting the iPhoto Events folder leaves Last Import intact. Importing new photos doesn't cause any further problems; the Last Import folder behaves as it always did, and should.



Out of curiosity I decided to find out what was causing Photos to place Last Import in the iPhoto Events folder in the first place.

Turns out, in my original iPhoto library, the folderUuid of Last Import was not 'LibraryFolder', but 'AllProjectsItem' — the same as the original Events category:

sqlite&gt; SELECT name, folderUuid FROM RKAlbum WHERE name = 'Last Import';
Last Import|AllProjectsItem
sqlite&gt; SELECT name, folderUuid FROM RKAlbum WHERE folderUuid = 'AllProjectsItem';
Events|AllProjectsItem
Last Import|AllProjectsItem


This is not the case in the fresh iPhoto library:

sqlite&gt; SELECT name, folderUuid FROM RKAlbum WHERE name = 'Last Import';
Last Import|LibraryFolder


Fixing the incorrect column in the original iPhoto library database (with the same UPDATE statement as above) seems to fix the Last Import folder when migrating to Photos as well. I think I'll go with this instead since it corrects both the old and new libraries.

Like in my previous question, I don't understand why or how my original iPhoto library reached that state in the first place, or why repairing/rebuilding the library didn't help at all. Was I bitten by a rare bug in iPhoto? Was I using iPhoto incorrectly? Either way, I'm lucky that I know a thing or two about SQLite and was therefore able to fix this on my own — if in the unlikely event someone has run into this very same issue, I hope this post will be helpful to them.

Once again, be sure to back up the entire library first.