-
Notifications
You must be signed in to change notification settings - Fork 86
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
How should an SQLite database migration file look like? #113
Comments
I successfully managed to get it working using: from peewee import Model
from peewee_migrate import Migrator, Router
from playhouse.sqlite_ext import SqliteExtDatabase
database = SqliteExtDatabase('file_convert.sqlite')
database.connect()
migrator = Migrator(database)
router = Router(database)
class BaseModel(Model):
class Meta:
database = database
class User(BaseModel):
...
migrator.create_table(User) # The most important part
router.migrator = migrator
router.run() |
@revolter This would create a sqlite-database for me with just an empty migratehistory table. The logging says:
Did you get it to do something useful? |
Take a look here for a complete, working example. |
I managed to piece together examples by looking at the tests https://github.com/klen/peewee_migrate/tree/develop/tests Would recommend the same to others, as documentation is sparse Setup Dependencies
|
The documentation is very lacking so it's not clear at all.
Firstly, in the
def migrate(migrator, database, fake=False, **kwargs):
method,migrator
is of typepeewee_migrate.migrator.Migrator
, so I have to usemigrator.migrator
to access thepeewee_migrate.migrator.SqliteMigrator
so it doesn't crashes. Is this the intended behavior?Secondly, I'm using
migrator.migrator.drop_not_null('user', 'username')
and nothing is happening. Isdrop_not_null
supported or not?The text was updated successfully, but these errors were encountered: