zerowords
zerowords

Reputation: 3113

Entity keys are different after migration to High Replication Datastore

My migration to hrd is not working on appspot.com . The app datastore has 3 "kind"s of data in both the original master/slave (MS) and in the High Replication Datastore (hrd): Group, Pin, and Log. Each Group entity has Pin entities and/or Log entities associated with it, but the associations no longer work in the hrd (which is all that survives the migration), so my app no longer works and I am looking for help to revive it.

Below I report the entity keys for the first two Pin entities in the datastore. I have inserted some spaces in the shorter key of each pair to facilitate lining up the keys to see their similarities. Notice that all the keys start and end similarly, but differ in MS vs hrd.

Decoded entity key: Group: name=250cc > Pin: id=1
Entity #1 MS  key: ah        NzaW1wbGlmeWNvbm5lY3Rpb25zchkLEgVHcm91cCIFMjUwY2MMCxIDUGluGAEM
Entity #1 hrd key: ahlzfnNpbXBsaWZ5Y29ubmVjdGlvbnMtaHJkchkLEgVHcm91cCIFMjUwY2MMCxIDUGluGAEM


Decoded entity key: Group: name=250cc > Pin: id=5001
Entity #2 MS   key: ah        NzaW1wbGlmeWNvbm5lY3Rpb25zchoLEgVHcm91cCIFMjUwY2MMCxIDUGluGIknDA
Entity #2 hrd  key: ahlzfnNpbXBsaWZ5Y29ubmVjdGlvbnMtaHJkchoLEgVHcm91cCIFMjUwY2MMCxIDUGluGIknDA

To view the app yourself use this link. You will see the Group named "Playground" and see how it is called in the URL. However, the only markers (map pins) that appear are ones that were added since the migration to hrd.

edit #0

Below is my Python code for adding saving a Pin where the parent is a Group.

elif action == "add":
            pin = Pin(parent=place)
            pin.name = self.request.get('details')
            pin.lat = float(self.request.get('lat'))
            pin.lng = float(self.request.get('lng'))
            pin.category = int(self.request.get('category'))
            pin.label = self.request.get('label')
            new_id = pin.put()
            self.response.out.write(new_id)

And below is the class definition for Pin.

class Pin(db.Model):
    date = db.DateTimeProperty(auto_now_add=True)
    lat = db.FloatProperty()
    lng = db.FloatProperty()
    name = db.StringProperty()
    cornerColor  = db.StringProperty(default='ffffff')
    height = db.IntegerProperty(default=32)
    label = db.StringProperty(default='')
    labelColor = db.StringProperty(default='000000')
    labelSize = db.IntegerProperty(default=2)
    primaryColor = db.StringProperty(default='ff0000')
    shadowColor = db.StringProperty(default='000000')
    shape = db.StringProperty(default='circle')
    strokeColor = db.StringProperty(default='000000')
    width = db.IntegerProperty(default=32)
    category = db.IntegerProperty(default=0)
    scategory = db.StringProperty()
    logindex = db.IntegerProperty(default=0)
    imageindex = db.IntegerProperty(default=0)
    deleteRequested = db.BooleanProperty(default=False)

edit #0

edit #1

The problem with my app is not with the entity keys, after all. Instead, the problem is with the way I tried to handle another deprecated Google (Maps) feature regarding stylized markers in my javascript/html.

I am sorry for the noise here. The problem resulted from my inability/ineptness with a try..catch pattern I attempted to employ as a workaround in the javascript/html template.

edit #1

Upvotes: 0

Views: 80

Answers (1)

Ryan
Ryan

Reputation: 100

The encoded key strings are expected to change. The encoded version contain the application's Id. During the migration process the keys are re-written with the new application Id. References to keys are also similarly updated.

If you store a key as a db.ReferenceProperty, the key is automatically updated for you during the migration.

However if you are storing strings like

ahNzaW1wbGlmeWNvbm5lY3Rpb25zchkLEgVHcm91cCIFMjUwY2MMCxIDUGluGAEM

in db.StringProperty() (or other similar ways, such as a part of a URL), then they will not be updated an you need to update yourself as described in the docs.

The model you reference for Pin, does not appear to link to other entities so there shouldn't be any problems.

Upvotes: 1

Related Questions