Closed graft closed 4 years ago
This was completed as described in https://github.com/mountetna/magma/pull/157. Now that we can define models in the database (https://github.com/mountetna/magma/pull/162), we can update the load_project command so it also loads models.
In #148 we gained the ability to load attributes from the attributes table. How is the attributes table populated? In the specs, the example
labors
project is being loaded from a YAML fixture.However, we already have a document format that attempts to describe the attributes for a project model completely:
Magma::Model#json_template
and the associatedMagma::Attribute#json_template
; These are usually returned by the Magma /retrieve endpoint, and are a standard tool for describing magma models (used, for example, by theModelMap
or theAttributeViewer
in Timur). We ought to be able to load attributes directly from these templates into a Magma instance's attributes (and models?) table.This would create a nice loop, where we can dump templates from one project or instance and load them into another. These project templates can be paired with associated migrations to allow easier deploy of new models. (Eventually we ought to be able to load + inflate the data graph, i.e., auto-migrate, this way.)
The command would simply take a template.json as might be output by the /retrieve endpoint as an argument, and would make entries into the
attributes
table using each model/attribute's JSON definition.