peewee_migrate icon indicating copy to clipboard operation
peewee_migrate copied to clipboard

`--auto` does not know fields from the Peewee Playhouse

Open dev-zero opened this issue 9 years ago • 3 comments

We are using the BinaryJSONField from the Playhouse module for PostgreSQL (see http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#postgres-ext).

The migrations file contains then the following:

    @migrator.create_model
    class Result(pw.Model):
        energy = pw.DoubleField()
        task = pw.ForeignKeyField(db_column='task_id', rel_model=Task, to_field='id')
        filename = pw.CharField(max_length=255, null=True)
        data = pw.BinaryJSONField(index=True, null=True)

while it should maybe be something like:

import playhouse.postgres_ext as pw_pext

[...]

    @migrator.create_model
    class Result(pw.Model):
        energy = pw.DoubleField()
        task = pw.ForeignKeyField(db_column='task_id', rel_model=Task, to_field='id')
        filename = pw.CharField(max_length=255, null=True)
        data = pw_pext.BinaryJSONField(index=True, null=True)

In the original models file I have:

from playhouse.postgres_ext import BinaryJSONField

dev-zero avatar Jul 07 '16 11:07 dev-zero

Same happens for me when using muffin_peewee. I have from muffin_peewee import JSONField in models yet migration too ends up having pw.JSONField.

It's not hard to manually change the migration but it would be awesome if it would automatically recognize to what a field belongs to. (maybe using inspect? I don't know specific inner workings of this library to give any more suggestions.)

zet4 avatar Jul 23 '16 16:07 zet4

Bump, will this be addressed in any way? Should we just create migrations manually?

bmlis avatar May 24 '17 08:05 bmlis

I have made a quick pr to fix this problem: https://github.com/klen/peewee_migrate/pull/56

NilsJPWerner avatar Sep 14 '17 15:09 NilsJPWerner