Giter VIP home page Giter VIP logo

Comments (3)

sanjok-bless avatar sanjok-bless commented on May 25, 2024

It would be great if there was an opportunity to customize imports. For my case:

from peewee import *
from db.fields import *   # my custom fields

instead of

import datetime as dt
import peewee as pw

So do not use the expression pw.Model, pw.CharField, ... but just Model, CharField, ...

It also would be great if I had the chance to make my custom fields understandable for peewee-migrate, they are based on the standard peewee fields. For example:

class AsciiCharField(CharField):
    def ddl_datatype(self, ctx):
        return SQL('VARCHAR(%s) CHARACTER SET ascii' % self.max_length)

class Example(BaseModel):
    name = CharField(max_length=200)
    ascii_chars = AsciiCharField(max_length=10)

peewee migrate ignore attributes of AsciiCharField, but it's the same as CharField... So far I have come up with only this way to improve the creation of migration of custom fields:

from peewee_migrate.auto import FIELD_TO_PARAMS

FIELD_TO_PARAMS.update({
    AsciiCharField: FIELD_TO_PARAMS[CharField],
})

But I'm not sure if this is correct. Сould you write an instruction how to improve the results of creating automatic migrations for custom fields and add the ability to adjust the template described above?

If not an instruction, then at least a couple of ideas? :)

from peewee_migrate.

trim21 avatar trim21 commented on May 25, 2024

Reply after one year...

By doing this:

from peewee_migrate import auto
from app.models.fields import SubtitleField  # noqa
import peewee as pw
auto.FIELD_MODULES_MAP['SubtitleField']='app.models.fields'

but the question is migrate file will not import app.models.fields automaicly,so you need to add it yourself.

from peewee_migrate.

trim21 avatar trim21 commented on May 25, 2024

And sad story, I can't find a easy way to extend template.txt, So i have to add that by myself.

And peewee_migrate will try to migrate these fields in every later migrations.

from peewee_migrate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.