2017-03-14 23:16:05 +01:00
|
|
|
//
|
|
|
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
|
|
|
//
|
2016-09-28 18:21:14 +02:00
|
|
|
|
|
|
|
#import "OWSDatabaseMigrationRunner.h"
|
|
|
|
#import "OWS100RemoveTSRecipientsMigration.h"
|
2017-01-24 01:48:14 +01:00
|
|
|
#import "OWS102MoveLoggingPreferenceToUserDefaults.h"
|
2017-03-14 23:16:05 +01:00
|
|
|
#import "OWS103EnableVideoCalling.h"
|
2017-05-23 17:28:12 +02:00
|
|
|
#import "OWS104CreateRecipientIdentities.h"
|
2016-09-28 18:21:14 +02:00
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
@implementation OWSDatabaseMigrationRunner
|
|
|
|
|
|
|
|
- (instancetype)initWithStorageManager:(TSStorageManager *)storageManager
|
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
if (!self) {
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
_storageManager = storageManager;
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray<OWSDatabaseMigration *> *)allMigrations
|
|
|
|
{
|
2016-11-08 19:08:04 +01:00
|
|
|
return @[
|
|
|
|
[[OWS100RemoveTSRecipientsMigration alloc] initWithStorageManager:self.storageManager],
|
2017-03-14 23:16:05 +01:00
|
|
|
[[OWS102MoveLoggingPreferenceToUserDefaults alloc] initWithStorageManager:self.storageManager],
|
2017-05-23 17:28:12 +02:00
|
|
|
[[OWS103EnableVideoCalling alloc] initWithStorageManager:self.storageManager],
|
|
|
|
[[OWS104CreateRecipientIdentities alloc] initWithStorageManager:self.storageManager]
|
2016-11-08 19:08:04 +01:00
|
|
|
];
|
2016-09-28 18:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)assumeAllExistingMigrationsRun
|
|
|
|
{
|
|
|
|
for (OWSDatabaseMigration *migration in self.allMigrations) {
|
|
|
|
DDLogInfo(@"%@ Skipping migration on new install: %@", self.tag, migration);
|
|
|
|
[migration save];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)runAllOutstanding
|
|
|
|
{
|
|
|
|
for (OWSDatabaseMigration *migration in self.allMigrations) {
|
|
|
|
if ([OWSDatabaseMigration fetchObjectWithUniqueID:migration.uniqueId]) {
|
|
|
|
DDLogDebug(@"%@ Skipping previously run migration: %@", self.tag, migration);
|
|
|
|
} else {
|
|
|
|
DDLogWarn(@"%@ Running migration: %@", self.tag, migration);
|
|
|
|
[migration runUp];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Logging
|
|
|
|
|
|
|
|
+ (NSString *)tag
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat:@"[%@]", self.class];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)tag
|
|
|
|
{
|
|
|
|
return self.class.tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|