-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with Django 1.7 migrations? #103
Comments
Oh no again. So, I don't really know how to proceed. Apart from just deleting part of the migration manually, which obviously sucks but will work if in a hurry, we could do two things:
Federico |
Bah! Okay, yeah I doubt that we'd get them to reopen the issue, especially given Django1.8's new HStoreField. Until I get a chance to see how 1.8 works, or until the DRF bug gets fixed, I think I'll just manually edit the migrations |
Ok @jannon. |
Can you paste the model field before and after? |
@jannon could you answer to @timgraham's question please? |
Before: class MyModel(models.Model):
hstore_field = hstore.DictionaryField(schema=[
{
'name': 'end_date',
'class': 'DateField',
'kwargs': {'null': True, 'blank': True}
}
], null=True, blank=True) After: class MyModel(models.Model):
hstore_field = hstore.DictionaryField(schema=[
{
'name': 'end_date',
'class': 'DateField',
'kwargs': {'null': True, 'blank': True, 'default': date(2015, 1, 1)}
}
], null=True, blank=True) |
I think the migration that's generated is correct, but Django doesn't seem to have good support for ignoring virtual fields in the schema editor. You might be able to workaround it by adding a This might be properly fixed if Django gains support for composite fields in 1.9, but it seems like a ticket is justified (a separate one from what was originally reported). |
thx for the info @timgraham, is there any link where we can find more information? A mailing list thread, a ticket, or anything else? |
More information about what? Composite field DEP is here if that's what you meant: django/deps#12 |
Exactly, thank you. |
@timgraham & @jannon I pushed a possible fix for the ValueError in e3ff9bf, the problem is I don't have a clue of how to make a failing test case ... 👎 any hints? |
You might take inspiration from Django's test suite: https://github.com/django/django/blob/master/tests/schema/tests.py |
Fixed VirtualField migration problems #103
It should be fixed. Thanks to everyone who helped out: @jannon for reporting, @timgraham and @apollo13 for helping me with suggestions. I opened a new thread on django-developers here: https://groups.google.com/forum/#!topic/django-developers/_FmJRK3sJGs I received another suggestion by @MarkusH which I'll try out before closing this issue. |
Federico, |
Avoid leaving migration files if the method test_migration fails or tests are interrupted. Related to #103
I mark this closed for the moment, but I'll keep following the mailing list for suggestions. |
I just ran my first migration on a model that has an hstore field in it. I had changed the default of a datetime field within the hstore field (because of encode/django-rest-framework#2687) and the migration blew up with:
So I took a look at what the migration was doing:
It seems like the django_hstore.virtual.VirtualField fields shouldn't be included in the migration. I wanted to check and see if others had this issue or if I was just missing something before I looked in to how we might avoid this (other than manually editing the migration every time)
The text was updated successfully, but these errors were encountered: