Migration.m 882 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // Migration.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2021/1/8.
  6. // Copyright © 2021 JCZ. All rights reserved.
  7. //
  8. #import "Migration.h"
  9. @interface Migration()
  10. @property (nonatomic, copy) NSString *myName;
  11. @property (nonatomic, assign) uint64_t myVersion;
  12. @property (nonatomic, strong) NSArray *updateArray;
  13. @end
  14. @implementation Migration
  15. - (instancetype)initWithName:(NSString *)name andVersion:(uint64_t)version andExecuteUpdateArray:(NSArray *)updateArray {
  16. if (self = [super init]) {
  17. _myName = name;
  18. _myVersion = version;
  19. _updateArray = updateArray;
  20. }
  21. return self;
  22. }
  23. - (NSString *)name {
  24. return _myName;
  25. }
  26. - (uint64_t)version {
  27. return _myVersion;
  28. }
  29. - (BOOL)migrateDatabase:(FMDatabase *)database error:(out NSError *__autoreleasing *)error {
  30. for (NSString *updateStr in _updateArray) {
  31. [database executeUpdate:updateStr];
  32. }
  33. return YES;
  34. }
  35. @end