Question

I realize that RavenDB doesn't use an actual schema, and is mostly just dependent on the shape of the object being passed in, but I am having a difficult time comprehending the way in which typical developers handle this in situations where the shape changes.

For example, I recently encountered a problem where we had a field named one thing, and it was a single value - and the client wanted it changed to a collection.

So the situation was ...

class [Name] {

  // properties
  // properties
  public ObjectType PropertyName { get; set; }
}

needed to become ...

class [Name] {
 // properties
 // properties
 public List<ObjectType> PropertyName { get; set; }
}

The only way I was able to do this was to create one new property of the correct type, but wrong name - and go through and perform a long, tedious operation of copying the data alllll over to it, then saving the changes everywhere. Then, deleting the old property, and saving the changes, then creating the new correct property, and going through the entire copy process again, and saving it. Meanwhile - the entire site was down during this time.

Is there a more intelligent way to handle this kind of scenario? I have looked at "patching", but it seems too limited for anything but very basic changes.

Was it helpful?

Solution

Ayende blogged about schema upgrades and when to perform them.

OTHER TIPS

I know a link is discouraged as an answer but it is a direct answer to (part of) the question

Dynamic fields

This does not really allow for renaming a field or change the type (from single to a collection).

I think a pitfall here is if zero are returned you might not know if the field name did not match or value did not match.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top