It also seems that the migrations are actually creating postgres columns for all the schema fields in hstore. which defeats the entire purpose of it.
The following model:
class DailyMetrics(models.Model):
person = models.ForeignKey(Person)
date = models.DateField()
resting_heart_rate_hstore_field = {
'name': 'resting_heart_rate',
'class': 'DecimalField',
'kwargs': {
'blank': True,
'null': True,
'max_digits': 6,
'decimal_places': 2
}
}
respiration_rate_hstore_field = {
'name': 'respiration_rate_rate',
'class': 'DecimalField',
'kwargs': {
'blank': True,
'null': True,
'max_digits': 6,
'decimal_places': 2
}
}
sleep_latency_hstore_field = {
'name': 'sleep_latency_rate',
'class': 'DecimalField',
'kwargs': {
'blank': True,
'null': True,
'max_digits': 6,
'decimal_places': 2
}
}
schema = [
resting_heart_rate_hstore_field,
respiration_rate_hstore_field,
sleep_latency_hstore_field
]
metrics = hstore.DictionaryField(schema=schema)
objects = hstore.HStoreManager()
Ends up in the following postgres table:
Table "public.sleeptracking_dailymetrics"
Column | Type | Modifiers | Storage | Description
-----------------------+--------------+-------------------------------------------------------------------------+----------+-------------
id | integer | not null default nextval('sleeptracking_dailymetrics_id_seq'::regclass) | plain |
person_id | integer | not null | plain |
date | date | not null | plain |
metrics | hstore | not null | extended |
resting_heart_rate | numeric(6,2) | not null | main |
respiration_rate_rate | numeric(6,2) | not null | main |
sleep_latency_rate | numeric(6,2) | not null | main |
Indexes:
"sleeptracking_dailymetrics_pkey" PRIMARY KEY, btree (id)
"sleeptracking_dailymetrics_person_id" btree (person_id)
Foreign-key constraints:
"person_id_refs_id_d35df919" FOREIGN KEY (person_id) REFERENCES sleeptracking_person(id) DEFERRABLE INITIALLY DEFERRED
Has OIDs: no