{"action":"created","issue":{"url":"https://api.github.com/repos/ZEROFAIL/goblin/issues/3","repository_url":"https://api.github.com/repos/ZEROFAIL/goblin","labels_url":"https://api.github.com/repos/ZEROFAIL/goblin/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/ZEROFAIL/goblin/issues/3/comments","events_url":"https://api.github.com/repos/ZEROFAIL/goblin/issues/3/events","html_url":"https://github.com/ZEROFAIL/goblin/issues/3","id":138842408,"number":3,"title":"Moving forward with Goblin - Utilities for working with Titan:db schema and indices","user":{"login":"davebshow","id":3734233,"avatar_url":"https://avatars.githubusercontent.com/u/3734233?v=3","gravatar_id":"","url":"https://api.github.com/users/davebshow","html_url":"https://github.com/davebshow","followers_url":"https://api.github.com/users/davebshow/followers","following_url":"https://api.github.com/users/davebshow/following{/other_user}","gists_url":"https://api.github.com/users/davebshow/gists{/gist_id}","starred_url":"https://api.github.com/users/davebshow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davebshow/subscriptions","organizations_url":"https://api.github.com/users/davebshow/orgs","repos_url":"https://api.github.com/users/davebshow/repos","events_url":"https://api.github.com/users/davebshow/events{/privacy}","received_events_url":"https://api.github.com/users/davebshow/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ZEROFAIL/goblin/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/ZEROFAIL/goblin/labels/help%20wanted","name":"help wanted","color":"159818"},{"url":"https://api.github.com/repos/ZEROFAIL/goblin/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-06T21:50:41Z","updated_at":"2016-03-07T16:43:42Z","closed_at":null,"body":"Hello everyone! I would like to discuss some plans for moving forward with goblin. The are some implementation details that still need some work, like error handling, logging, etc.,  but the library is basically up and running. The next big hurdle will be figuring out how to implement some tools for working with Titan's modelling API. I noticed that Cody implemented some model syncing functionality in the original mogwai library, but I haven't looked too closely at it, and I don't know if it ever was actually integrated into the main library.\r\n\r\nMy initial thought is to provide a series of functions that can perform schema definitions supported by Titan:db [1]. Basically, we would be able to:\r\n\r\n1. Create new elements (vertex, edge, property), and define their data types as well as cardinality.\r\n\r\n2. Change element names (Titan does not allow changing data type etc.).\r\n\r\n3. Define static vertices, TTL and undirected edges [2].\r\n\r\nRegarding the implementation of this functionality, I want to do something like already suggested by the original mogwai design. The process would be something like this:\r\n\r\n```python\r\n>>> generate_specfile(path_to_model_definition=\"models.py\", ...)\r\n```\r\n\r\nThe ``generate_specfile`` function inspects the file containing the ``goblin`` model definition and creates a simple JSON style data structure that contains the vertices, edges, and associated properties, which is dumped to a file ``current_spec.json``.\r\n\r\n```\r\n\"[{\r\n    \"verticies\": [{\"label\": \"person\", ..., \"properties\": []}]\r\n    \"edges\": ...\r\n}]\"\r\n```\r\nWe then check to see if there is already a spec file associated with the app. If there is, we do a series of simple comparisons to check if there are:\r\n\r\n1. Missing Vertices/Edges/Properties\r\n2. New Vertices/Edge/Properties\r\n\r\n```python\r\n>>> sync_spec(new_specfile, old_specfile)\r\n```\r\nIf there are missing properties, we add this to a list of unused properties that can be reused. Missing vertices/edges are cataloged as unused elements. If there are \"new properties\" (could be an old property with a name change), we look through the unused properties. If there is an unused property with the proper data type and cardinality, we can recycle it by changing its name using Titan's API. If there are new vertices/edges, they will be created. Optionally, we could allow the user to pass element renaming mappings to allow name changes on vertices and edges, or other functionality to help the process along.\r\n\r\nFinally, we output a new spec file that reflects the current state of the Schema, which includes the name changes made during the sync, as well as all of the unused elements.\r\n\r\nOf course, if this is the first sync, we simply create the schema based on the specfile,\r\n\r\nWhile this system isn't perfect, it could be pretty handy, especially for adding new models or simple property name changes.\r\n\r\nRegarding indices [3], I assume we would like to allow the user to define their own indices on the models, which will be created on model sync. Elements created before index definition can be easily reindexed. \r\n\r\nAny ideas @jsenecal or @leifurhauks?\r\n\r\n1. http://s3.thinkaurelius.com/docs/titan/1.0.0/schema.html\r\n2. http://s3.thinkaurelius.com/docs/titan/1.0.0/advanced-schema.html\r\n3. http://s3.thinkaurelius.com/docs/titan/1.0.0/indexes.html"},"comment":{"url":"https://api.github.com/repos/ZEROFAIL/goblin/issues/comments/193338817","html_url":"https://github.com/ZEROFAIL/goblin/issues/3#issuecomment-193338817","issue_url":"https://api.github.com/repos/ZEROFAIL/goblin/issues/3","id":193338817,"user":{"login":"leifurhauks","id":5378335,"avatar_url":"https://avatars.githubusercontent.com/u/5378335?v=3","gravatar_id":"","url":"https://api.github.com/users/leifurhauks","html_url":"https://github.com/leifurhauks","followers_url":"https://api.github.com/users/leifurhauks/followers","following_url":"https://api.github.com/users/leifurhauks/following{/other_user}","gists_url":"https://api.github.com/users/leifurhauks/gists{/gist_id}","starred_url":"https://api.github.com/users/leifurhauks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leifurhauks/subscriptions","organizations_url":"https://api.github.com/users/leifurhauks/orgs","repos_url":"https://api.github.com/users/leifurhauks/repos","events_url":"https://api.github.com/users/leifurhauks/events{/privacy}","received_events_url":"https://api.github.com/users/leifurhauks/received_events","type":"User","site_admin":false},"created_at":"2016-03-07T16:43:42Z","updated_at":"2016-03-07T16:43:42Z","body":"This sounds like a good system to me!"}}