Determine type column values for Namespace subclasses
Currently we have two different aspects that we use to identify what kind of Namespace
we're dealing with.
-
kind
which is a method on the model -
type
which is a DB field.
Currently we have the following:
-
Namespace
- kind:
user
- type:
nil
- kind:
-
Group
- kind:
group
- type:
Group
- kind:
Let's use type
and phase out kind
, and also make an effort to reduce database storage of unnecessary characters.
@digitalmoksha specifies in !68825 (comment 664632991):
One small concern I have - if we just use the default mappings, then the types in the
type
column will becomeNamespaces::ProjectNamespace
,Namespaces::UserNamespace
, and eventuallyNamespaces::GroupNamespace
. Rather thanProject
,User
, and today'sGroup
. It feels a little wasteful on characters.
I think we can override that behavior by adjusting
store_full_sti_class
,store_full_class_name
, and I thinksti_name
andsti_class_for
. But I haven't gotten that working yet cleanly in theUserNamespace
case.
Also, he writes in !68825 (comment 666478387):
The code above also needs to handle the
null
value for user namespace.Believe it or not (and unfortunately), it doesn't need to. STI is not invoked unless the
type
column exists and there is value in it. At least based on my testing.I think it is worth being consistent. I mean I don't think we'd want the
Group
,Namespaces::ProjectNamespace
andnull
(current value for user namespace) values in thenamespaces#type
field😬 🤷 I agree, I'm working on the
User
angle right now in !68894 (merged)I agree values should be consistent. Whether to store shorter or "full" names depends if there is a noticeable DB benefit. If it doesn't matter from DB POV, I wonder if it's worth it (as it would be just extra logic to maintain)?
I agree, if there is no benefit, it's not really necessary (though we will be able to use that trick during the time we/if transition the
Group
toNamespaces::GroupNamespace
).
@ahegyi
up to you - for thenamespaces
table, should we care about whether each record's type column has one ofNamespaces::GroupNamespace
,Namespaces::ProjectNamespace
, andNamespaces::UserNamespace
, or they would beGroup
,Project
,User
?