Migrate EventHistory database to Application Support directory#1186
Merged
sbenedicadb merged 11 commits intoadobe:dev-v5.7.0from Sep 17, 2025
Merged
Migrate EventHistory database to Application Support directory#1186sbenedicadb merged 11 commits intoadobe:dev-v5.7.0from
sbenedicadb merged 11 commits intoadobe:dev-v5.7.0from
Conversation
…t to application support directory away from caches directory
praveek
reviewed
Sep 12, 2025
| static let dbName = "com.adobe.eventHistory" | ||
| static let dbSubdirectoryName = "com.adobe.aep.db" | ||
| static let dbNameWithSubdirectory = dbSubdirectoryName + "/" + dbName | ||
| static let dbFilePath: FileManager.SearchPathDirectory = .applicationSupportDirectory |
praveek
reviewed
Sep 12, 2025
| static let dbSubdirectoryName = "com.adobe.aep.db" | ||
| static let dbNameWithSubdirectory = dbSubdirectoryName + "/" + dbName | ||
| static let dbFilePath: FileManager.SearchPathDirectory = .applicationSupportDirectory | ||
| static let legacyDbFilePath: FileManager.SearchPathDirectory = .cachesDirectory |
praveek
reviewed
Sep 12, 2025
| /// - subDirectory: a sub directory to `databaseFilePath` that contains the database | ||
| /// - databaseName: the database name | ||
| /// - Returns: the database connection | ||
| public static func connect(databaseFilePath: FileManager.SearchPathDirectory, subDirectory: String, databaseName: String) -> OpaquePointer? { |
Contributor
There was a problem hiding this comment.
databaseFilePath is confusing. Let’s rename it to databaseDirectoryPath, even though it deviates from the current function’s naming convention, since we may eventually migrate all extensions to use this function.
praveek
reviewed
Sep 17, 2025
| let fileManager = FileManager.default | ||
|
|
||
| // most common scenario is that the database has already been migrated, so check that first | ||
| if let existingNewDbUrl = fileManager.urls(for: EventHistoryConstants.applicationSupportDirectory, in: .userDomainMask).first?.appendingPathComponent(EventHistoryConstants.dbNameWithSubdirectory) { |
Contributor
There was a problem hiding this comment.
nit: More readable if you use the same pattern as line 29.
if let existingNewDbUrl = ....., fileExists(atPath: existingNewDbUrl.path) {
return
}
praveek
reviewed
Sep 17, 2025
|
|
||
| clearCachedItems(cacheItems, in: .cachesDirectory) | ||
|
|
||
| let migratedEventHistoryDb = [(name: "com.adobe.aep.db/com.adobe.eventHistory", isDirectory: false)] |
Contributor
There was a problem hiding this comment.
nit: Should be simpler to delete the entire directory
praveek
approved these changes
Sep 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
[APP_DIR]/Library/Caches/com.adobe.eventHistory[APP_DIR]/Library/Application Support/com.adobe.aep.db/com.adobe.eventHistoryEventHistoryDatabaseMigrator.swifteventHubQueuequeueSQLiteWrapper's connect functionFileManagerto allow easy creation of directories when they don't existRelated Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: