Improve the ORM object names
Issue
The ORM is meant to be an object oriented abstraction on top of the underlying SQL database. For some reason, all ORM object names as defined in orchestrator/db/models.py end in Table:
FixedInputTable
ProcessStepTable
ProcessSubscriptionTable
ProcessTable
ProductBlockRelationTable
ProductBlockTable
ProductTable
ResourceTypeTable
SubscriptionCustomerDescriptionTable
SubscriptionInstanceRelationTable
SubscriptionInstanceTable
SubscriptionInstanceValueTable
SubscriptionMetadataTable
SubscriptionTable
WorkflowTable
when used in code, this does not provide the best readability experience:
def all_subscriptions() -> list[SubscriptionTable]:
return SubscriptionTable.query.all()
in this example SubscriptionTable could better be replaced by Subscription.
Other object names can be confusing, like SubscriptionInstanceTable, that could have been named ProductBlockInstance, or maybe rename ProductBlock to ProductBlockType and rename SubscriptionInstanceTable to ProductBlock.
Proposal
Come up with a list of better object names and refactor the code base accordingly.
Advantage:
- Improve readability of the code and the logic that it implements
Disadvantage:
- Every user of the orchestrator-core has to refactor its own implementation as well
This ticket could also be combined by renaming the db tables and column, the minimal change could be:
Anyway the proposed new naming would as a minimum:
| Table | ok? | New table name | New table column names |
|---|---|---|---|
| subscription_instances | no | product_block_instances | subscription_instance_id --> product_block_instance_id OK: subscription_id, product_block_id, label (can be removed) |
| subscription_instance_values | no | product_block_instance_values | subscription_instance_id --> product_block_instance_id subscription_instance_value_id --> resource_type_instance_id OK: resource_type_id, value" |
| subscription_instance_relations | no | product_block_instance_relations | ok |
- Main impact in de opensource code can be addressed by a find replace
- In the custom code of other deployments besides SURF will require quite a bit of guidance (migration guide?)
An even better implementation is to change product_block to product_block_type and change product_block_instance to product_block
There are two ways we could go about this. I feel we could rename everything to be Product centric or Subscription centric. I will give the example below:
Product centric
| Old | New |
|---|---|
| Product | Product |
| ProductBlock | ProductBlock |
| ResourceType | ProductBlockAttribute |
| FixedInput | ProductFixedAttribute |
| Subscription | ProductInstance |
| SubscriptionInstance | ProductBlockInstance |
| SubscriptionInstanceValue | ProductBlockAttributeValue |
| SubscriptionInstanceRelations | ProductBlockInstanceRelations |
| ProductBlockRelations | ProductBlockRelations |
| ProductBlockResourceTypes | ProductBlockProductBlockAttribute |
Subscription centric
| Old | New |
|---|---|
| Product | SubscriptionDefinition |
| ProductBlock | SubscriptionBlockDefinition |
| ResourceType | SubscriptionBlockAttributeDefinition |
| FixedInput | SubscriptionFixedAttributeDefinition |
| Subscription | Subscription |
| SubscriptionInstance | SubscriptionBlock |
| SubscriptionInstanceValue | SubscriptionBlockAttribute |
| SubscriptionInstanceRelations | SubscriptionBlockRelations |
| ProductBlockRelations | SubscriptionBlockRelationsDefinition |
| ProductBlockResourceTypes | SubscriptionBlockSubscriptionBlockAttributes |
| Old | New |
|---|---|
| Product | Product -- no change |
| FixedInput | ProductFixedAttribute |
| ProductBlock | ProductBlock -- no change |
| ResourceType | ProductBlockAttribute |
| ProductBlockRelations | ProductBlockRelations -- no change |
| ProductBlockResourceTypes | ProductBlockAttributes |
| Subscription | Subscription -- no change |
| SubscriptionInstance | SubscriptionProductBlock |
| SubscriptionInstanceValue | SubscriptionProductBlockAttribute |
| SubscriptionInstanceRelations | SubscriptionProductBlockRelations |