mountetna / magma

Data server with friendly data loaders
GNU General Public License v2.0
5 stars 2 forks source link

Add column_name to the attributes table so attribute_name is editable #199

Closed alimi closed 3 years ago

alimi commented 3 years ago

With this change, a Magma::Attribute's attribute_name can be changed at any time without also requiring a migration to the Magma::Attribute's project table. This is accomplished by adding a column_name column to the attributes table.

To help verify this new behavior, I changed a few attribute_names to make them different from their column_names. A few things came out as a result:

  1. Change Magma::Model.identity so it holds the identifier attribute instead of a symbol. Now that attribute_name and column_name can be different, a symbol with one of those values is no longer sufficient.
  2. Magma::Model.identity will fallback to a default primary key identifier for models who don't specify identifiers. This will make Magma::Model.identity's behavior consistent across the board.
  3. Pass full attribute object to Magma::ColumnPredicates so the predicates can get column_name and attribute_name as needed.
  4. Define alias methods on Magma::Models for attributes that have different attribute_name/column_name because Sequel will only define methods based on column_name.