Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrations #342

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9de90a3
migration interfaces
alazier May 27, 2014
cfc8f21
headers
alazier May 27, 2014
f43a6df
add missing version (needed when implementing migration block)
alazier May 27, 2014
6cd5236
updated interfaces
alazier May 28, 2014
1edd0fc
merge
alazier May 28, 2014
b999d80
fixes for JP's comments
alazier May 28, 2014
540d5da
pass old version in migration block
alazier May 28, 2014
1298d6d
merge from master
alazier May 30, 2014
604efb2
merge fixes
alazier May 30, 2014
7e295ff
merge
alazier Jun 10, 2014
60bb11e
make schema private
alazier Jun 10, 2014
b5a451c
Merge branch 'master' into al-migration
alazier Jun 12, 2014
415791f
initial implementation for migrations
alazier Jun 12, 2014
8aea6ec
Merge branch 'master' into al-migration
alazier Jun 17, 2014
04ead8b
merge
alazier Jun 20, 2014
3d84bfc
merge
alazier Jun 20, 2014
eaa1105
fix for headers
alazier Jun 23, 2014
09441fa
use single accessor class to avoid c-accessor edge cases, true dynami…
alazier Jun 23, 2014
f48f2a1
add migrations
alazier Jun 24, 2014
919840a
fix for compile issues
alazier Jun 24, 2014
dac9d1d
Merge branch 'master' into al-migration
alazier Jun 24, 2014
405aa62
use 2 realms during migration
alazier Jun 24, 2014
798d4d2
private interface for schema mutation
alazier Jun 24, 2014
93e96d9
first migration test
alazier Jun 25, 2014
2ba2df9
fix for wrong accessors, less string copying, remove unnecessary ivar…
alazier Jun 25, 2014
3ec4bd3
fix for build error for ios
alazier Jun 25, 2014
6237af2
more outdated accessors
alazier Jun 25, 2014
ce49fcb
fix for object enumeration
alazier Jun 25, 2014
aa4c020
add ability to create objects directly from arrays/dictionaries
alazier Jun 25, 2014
083a666
finish test
alazier Jun 25, 2014
2d7f8fc
add tests
alazier Jun 25, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
merge
  • Loading branch information
alazier committed Jun 20, 2014
commit 04ead8bead3b8d51ef69d434e7289ef5b63c3076
2 changes: 1 addition & 1 deletion Realm/RLMObjectSchema.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#import "RLMProperty_Private.h"
#import "RLMSchema_Private.h"
#import "RLMObject_Private.h"
#import "RLMUtil.h"
#import "RLMUtil.hpp"

#import <tightdb/table.hpp>

Expand Down
2 changes: 0 additions & 2 deletions Realm/RLMObjectStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,3 @@ RLMArray *RLMGetObjects(RLMRealm *realm, NSString *objectClassName, NSPredicate

// Create accessors
RLMObject *RLMCreateObjectAccessor(RLMRealm *realm, NSString *objectClassName, NSUInteger index);


5 changes: 2 additions & 3 deletions Realm/RLMObjectStore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ void RLMInitializeObjectStore() {
});
}


// get the table used to store object of objectClass
inline tightdb::TableRef RLMTableForObjectClass(RLMRealm *realm,
NSString *className) {
Expand Down Expand Up @@ -114,15 +113,15 @@ void RLMVerifyAndCreateTables(RLMRealm *realm) {
// first pass create missing tables and verify existing
for (RLMObjectSchema *objectSchema in realm.schema.objectSchema) {
tightdb::TableRef table = RLMTableForObjectClass(realm, objectSchema.className);
if (!table->is_empty()) {
if (table->get_column_count()) {
RLMVerifyTable(table.get(), objectSchema);
}
}

// second pass add columns to empty tables
for (RLMObjectSchema *objectSchema in realm.schema.objectSchema) {
tightdb::TableRef table = RLMTableForObjectClass(realm, objectSchema.className);
if (table->is_empty()) {
if (table->get_column_count() == 0) {
for (RLMProperty *prop in objectSchema.properties) {
RLMCreateColumn(realm, table.get(), prop);
}
Expand Down
4 changes: 2 additions & 2 deletions Realm/RLMRealm.mm
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ + (instancetype)realmWithPath:(NSString *)path
}
else {
// set the schema for this realm
realm->_schema = [RLMSchema sharedSchema];
realm.schema = [RLMSchema sharedSchema];

// initialize object store for this realm
RLMVerifyAndCreateTables(realm);

Expand Down
4 changes: 2 additions & 2 deletions Realm/RLMSchema.mm
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ +(instancetype)dynamicSchemaFromRealm:(RLMRealm *)realm {

inline tightdb::TableRef RLMVersionTable(RLMRealm *realm) {
tightdb::TableRef table = realm.group->get_table(c_metadataTableName);
if (table->is_empty()) {
if (table->get_column_count() == 0) {
// create columns
table->add_column(tightdb::type_Int, c_versionColumnName);

Expand All @@ -147,7 +147,7 @@ +(instancetype)dynamicSchemaFromRealm:(RLMRealm *)realm {
}

NSUInteger RLMRealmSchemaVersion(RLMRealm *realm) {
return (*RLMVersionTable(realm))[0].get_int(c_versionColumnIndex);
return (NSUInteger)(*RLMVersionTable(realm))[0].get_int(c_versionColumnIndex);

}

Expand Down
25 changes: 8 additions & 17 deletions Realm/Tests/ObjectTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,7 @@

#import "RLMTestCase.h"

//
// Private Realm methods
//
@interface RLMRealm ()
-(RLMSchema *)schema;
@end


//
// Test Objects
//
@interface SimpleObject : RLMObject
@property NSString *name;
@property int age;
@property BOOL hired;
@end
#pragma mark - Test Objects

#pragma mark DefaultObject

Expand Down Expand Up @@ -97,6 +82,12 @@ + (RLMPropertyAttributes)attributesForProperty:(NSString *)propertyName
}
@end

#pragma mark - Private

@interface RLMRealm ()
@property (nonatomic) RLMSchema *schema;
@end

#pragma mark - Tests

@interface ObjectTests : RLMTestCase
Expand Down Expand Up @@ -507,7 +498,7 @@ - (void)testIndex
RLMProperty *nameProperty = [[RLMRealm defaultRealm] schema][IndexedObject.className][@"name"];
XCTAssertTrue(nameProperty.attributes & RLMPropertyAttributeIndexed, @"indexed property should have an index");

RLMProperty *ageProperty = [RLMRealm defaultRealm].schema[IndexedObject.className][@"age"];
RLMProperty *ageProperty = [[RLMRealm defaultRealm] schema][IndexedObject.className][@"age"];
XCTAssertFalse(ageProperty.attributes & RLMPropertyAttributeIndexed, @"non-indexed property shouldn't have an index");
}

Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.