From 82c1dbeabf48de6dd71fb3a5297e085353f16bd4 Mon Sep 17 00:00:00 2001 From: Jason Gessner Date: Mon, 23 Jun 2025 13:13:18 +0000 Subject: [PATCH 1/2] Add some simple instructions for adding new attributes to entities. --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 1644f1c..ff85971 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,17 @@ To import decklists from NRDB Classic, use bundle exec rake import_decklists:import[2024-11-09] ``` +## Adding attributes to entities + +To add attributes to entites, follow this general process: + +1. Add a new migration with a command like `bundle exec rails g active_record:migration AddFooToCardCycle` +2. Update the migration to add new fields and any indexes to the tables. See the `db/migrate/` folder for examples. +3. If this is an attribute that needs to be updated for the Card or Printing objects, update the materialized views for those entities with the instructions below. +4. Update the models with any needed relationships. +5. Add the new attributes and any needed filters to the appropriate resource file in `app/resources/`. +6. If you have changes to the `search` filter syntax for `Cards` or `Printings`, update the search query builder in `lib/search_query_builder.rb` using the `card`, `printing`, or `both` functions as appropriate for the attribute. + ## Updating materialized views We use a number of materialized views to make certain things that would be large, multi-table joins into single table queries. From f2fdfcd23880e349d327c354f1eab8b0714b488b Mon Sep 17 00:00:00 2001 From: Jason Gessner Date: Mon, 23 Jun 2025 13:23:20 +0000 Subject: [PATCH 2/2] Add new Entity docs. --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index ff85971..7fc5a3a 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,13 @@ To import decklists from NRDB Classic, use ```sh bundle exec rake import_decklists:import[2024-11-09] ``` +## Adding new entities + +To add a new entity, follow this rough process: + +1. Add a new migration with a command like `bundle exec rails g active_record:model CreateFoo`. +2. Add a new resource for the model, using the files in `app/resources/` as an example. +3. Update `config/routes.rb` to add a route for the resource. ## Adding attributes to entities