craftsmancoding / repoman

Repoman allows for easy package development in MODX Revolution. Take back the simplicity!
30 stars 7 forks source link

Parent/Child modResource JSON seed data issue. #39

Open zaigham opened 9 years ago

zaigham commented 9 years ago

As per twitter conversation: https://twitter.com/craftsmancoding/status/615949782897463296

The following dataset only created parent page. and thats it. Please see the data sample below:

[
    {
        "type": "document",
        "contentType": "text/html",
        "pagetitle": "Parent Page",
        "longtitle": "",
        "description": "",
        "alias": "s",
        "link_attributes": "",
        "published": true,
        "pub_date": 0,
        "unpub_date": 0,
        "parent": 0,
        "isfolder": true,
        "introtext": "",
        "content": "Some Content",
        "richtext": false,
        "template": 0,
        "menuindex": 8,
        "searchable": false,
        "cacheable": false,
        "createdby": 39,
        "createdon": "2013-12-10 23:02:37",
        "editedby": 900,
        "editedon": "2015-03-23 18:06:46",
        "deleted": false,
        "deletedon": 0,
        "deletedby": 0,
        "publishedon": "2013-12-10 23:07:00",
        "publishedby": 39,
        "menutitle": "",
        "donthit": false,
        "privateweb": false,
        "privatemgr": false,
        "content_dispo": 0,
        "hidemenu": true,
        "class_key": "modDocument",
        "context_key": "web",
        "content_type": 1,
        "uri": "s/",
        "uri_override": 0,
        "hide_children_in_tree": 0,
        "show_in_tree": 1,
        "properties": null,
        "children": {
            "type": "document",
            "contentType": "text/html",
            "pagetitle": "Child of Parent Page",
            "longtitle": "",
            "description": "",
            "alias": "product",
            "link_attributes": "",
            "published": true,
            "pub_date": 0,
            "unpub_date": 0,
            "isfolder": false,
            "introtext": "",
            "content": "Some Content",
            "richtext": false,
            "template": 0,
            "menuindex": 6,
            "searchable": false,
            "cacheable": true,
            "createdby": 39,
            "createdon": "2013-12-16 12:51:59",
            "editedby": 39,
            "editedon": "2015-03-26 19:45:47",
            "deleted": false,
            "deletedon": 0,
            "deletedby": 0,
            "publishedon": "2013-12-16 14:02:00",
            "publishedby": 39,
            "menutitle": "",
            "donthit": false,
            "privateweb": false,
            "privatemgr": false,
            "content_dispo": 0,
            "hidemenu": true,
            "class_key": "modDocument",
            "context_key": "web",
            "content_type": 1,
            "uri": "s/profile",
            "uri_override": 1,
            "hide_children_in_tree": 0,
            "show_in_tree": 1,
            "properties": null
        }
    }
]
fireproofsocks commented 9 years ago

Case matters for aliases: it must be "Children" -- use the graph function to help identify the aliases available.

zaigham commented 9 years ago

I just fixed the case, and ran seed command. I got this error:

ERROR:  build_attributes not set for modResource-->Children in composer.json. Make sure your definitions include "related_objects" and "related_object_attributes"

Would you please shed some light on this?

fireproofsocks commented 9 years ago

For each object, you need to describe its behavior when it comes to primary key, creates vs. updates, etc. This is done via the build_attributes. E.g. look at https://github.com/craftsmancoding/repoman/wiki/composer.json

So you could include something like the following in your "extra" --> "build_attributes" node in your composer.json:

"build_attributes":{
    "modResource": {
        "preserve_keys": true,
        "update_object": true, 
        "unique_key": ["alias"],
        "related_objects": true,
        "related_object_attributes": {  
            "Children": {
                "preserve_keys":        
                "update_object": true, 
                "unique_key": ["alias"]
            }
        }
    }
}
zaigham commented 9 years ago

I have tried this, still couldnt get the children docs in there. The data is same as above json.

This is my buid_attributes section:

"build_attributes":{
            "modResource": {
                "preserve_keys": true,
                "update_object": true, 
                "unique_key": ["alias"],
                "related_objects": true,
                "related_object_attributes": {  
                    "Children": {
                        "preserve_keys": true,
                        "update_object": true, 
                        "unique_key": ["alias"]
                    }
                }
            }
        }
fireproofsocks commented 9 years ago

Hmm... I'll have to troubleshoot and write up a tutorial.