South cannot freeze fields

67 views
Skip to first unread message

Leon Sasson

unread,
Aug 12, 2014, 12:01:17 AM8/12/14
to django...@googlegroups.com
Hi there,

Just started using django-hstore, and it seems very promising!

The schemaless fields work just fine, but I was trying to add a field with schema, and when migrating via south I get something along:

 ! Cannot freeze field 'surveys.sessionentry.date'
 ! (this field has class django_hstore.virtual.VirtualField)

For every field in my schema. I'm on Django 1.6.5, hstore 1.3, South 0.8.1.

Is this supported and I'm missing something or migrations via South are not supported for django-hstore fields with a schema?

Thanks,
Leon Sasson

Leon Sasson

unread,
Aug 12, 2014, 11:01:03 AM8/12/14
to django...@googlegroups.com
Just realized you released schemas last week. Good job on that. I understand if there are problems and I'll be happy to contribute as I think these Schemas are a great balance between actual postgres schemas and schemaless HStore.

Leon Sasson

unread,
Aug 12, 2014, 12:38:15 PM8/12/14
to django...@googlegroups.com
Tried replicating the issue on a fresh django project and it does work smoothly.
Now I'm totally confused as to why I keep getting the same migration errors on my actual django project.

nemesis

unread,
Aug 17, 2014, 4:15:47 AM8/17/14
to django...@googlegroups.com
Hi Leon,

I get what you mean as I got that problem with django 1.7 migration framework too.
We are talking about a different issue than this one: https://github.com/djangonauts/django-hstore/issues/57 - right?

Are you working with the pypi version or the dev version?

Could you try these steps:

- update to the last dev version
- delete the south migration file
- recreate the south schema migration file
- try running it

And tell us what happens?
Federico

Leon Sasson

unread,
Aug 18, 2014, 12:16:56 PM8/18/14
to django...@googlegroups.com
I'm not sure if I was referring to issue #57, as in my case South fails to generate migration files. 

I was on the pypi version, and after trying with the dev version, south does generate the appropriate migration files.

Let me know if you need anything else and if I can be of any help!

I will be sticking to the pypi version on my main project for now as I rather have that stability, but I'd be happy to play around with dev if needed.

LS


--
You received this message because you are subscribed to a topic in the Google Groups "django-hstore" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-hstore/DLvTeXx3cZE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-hstor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

nemesis

unread,
Aug 25, 2014, 4:53:28 AM8/25/14
to django...@googlegroups.com
Thanks for the feedback.

I understood your problem and I knew the latest changes would fix it.

I'll publish a new release soon, probably today.

Federico


On Monday, August 18, 2014 6:16:56 PM UTC+2, Leon Sasson wrote:
I'm not sure if I was referring to issue #57, as in my case South fails to generate migration files. 

I was on the pypi version, and after trying with the dev version, south does generate the appropriate migration files.

Let me know if you need anything else and if I can be of any help!

I will be sticking to the pypi version on my main project for now as I rather have that stability, but I'd be happy to play around with dev if needed.

LS

Leon Sasson

unread,
Aug 25, 2014, 1:14:07 PM8/25/14
to django...@googlegroups.com
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


--

nemesis

unread,
Aug 26, 2014, 4:33:14 AM8/26/14
to django...@googlegroups.com
Hi Leo,

You are right, I noticed this yesterday.
I did intensive testing both with south and django 1.7 makemigrations and I fixed it for both cases.
I wanted to warn you yesterday I was fixing the issues but I forgot :-)

Try the fresh 1.3.1 release.

Federico
Reply all
Reply to author
Forward
0 new messages