![]() If you have any questions, feel free to reach out. Yet, the master branch combines them into more complete solution. Also note the heitor, tom and dmitry branches, which have different approaches to the same problem. Old records stay valid and usable if the default value of the schema changes, and querying inside the description is ok due to PostgreSQL power with JSONB fields.Ī complete version of this idea can be seen in this GitHub repo. With the schema definition and a little Rails magic, we also enable validations. We are now able to have a relational database delivering multiple records of the same table, each one with different set of attributes. Remember that with JSONB, we have indexes called GIN / GiST to help with performance. # description->sound = 'Pioneer' Vehicle. ![]() We want every new instance of vehicle to have its schema filled by a default value declared in the database table. Required fields are also being declared in the schema for later validations. This enables us to have a different set of attributes for each record of the table. The schema defines attributes, telling us their type and default value. It held a schema and a description keeping its characteristics. After we did some brainstorming and white board sessions, we decided to start with a Model called Vehicle. This was a joint effort between me, Tom Rothe and Dmitry Parshenko. That was easily solved with a JSON field, but we also wanted to support validations on this field – validations that are assigned to the model at the time of creation. We knew that the columns for one particular model would need to change over time. JSON dynamic attributes with Rails we are 3-in-1: a technologist, a trainer, an organizer.
0 Comments
Leave a Reply. |