keredson / peewee-db-evolve

Automatic migrations for the Peewee ORM.
GNU Lesser General Public License v3.0
126 stars 26 forks source link

Ignore Model/Table #24

Closed augustoccesar closed 6 years ago

augustoccesar commented 6 years ago

Is there a way to ignore some model/table? In my app I have a default Base Model, from which the others are extended.

class BaseModel(Model):
    class Meta:
        database = database

And because of that, the migrations tries to migrate it...

Your database needs the following change:

  BEGIN TRANSACTION;

  CREATE TABLE "basemodel" ("id" SERIAL NOT NULL PRIMARY KEY); 

  COMMIT;
keredson commented 6 years ago

yes. in your Meta class add evolve = False. sorry, that should be documented.

augustoccesar commented 6 years ago

Okay! No problem 😄 But really would be nice to be on the documentation for new people 🤔 And thanks for the fast response!

augustoccesar commented 6 years ago

But at any case I don't think it will work for me 🤔 Since all the models will extend the evolve = False 🤔

keredson commented 6 years ago

https://github.com/keredson/peewee-db-evolve/commit/50a22bda9d07a19edb9780862988585799cb0dd4#diff-04c6e90faac2675aa89e2176d2eec7d8

keredson commented 6 years ago

hmmm... fair point. i'm not sure i have a good solution for you then. (other than the very hacky "just ignore the empty table" response.) i always just put database=database on each individual model. :)

what do you think about an ignore_tables kwarg on evolve()?

augustoccesar commented 6 years ago

@keredson Yeah, that was exactly what I was searching on your code: a way to ignore tables by its names on evolve(). I thing it is a good idea 🤔

And I don't do the database=database on each model because I have some more configuration for the database that I do together with the BaseModel when the app is loaded. But it is a solution that I can work around if not possible to do the idea that we talked about above 😄

keredson commented 6 years ago

what do you think about that?

augustoccesar commented 6 years ago

Yep, it looks perfect! 👍

keredson commented 6 years ago

cool. peewee-db-evolve-0.6.8 released.

keredson commented 6 years ago

also https://github.com/keredson/peewee-db-evolve/commit/a3cf25c108e7533a073fdbce77ac5e1da22128ec#diff-04c6e90faac2675aa89e2176d2eec7d8