I'm trying to use peewee's migration module to rename a column from name
to title
in my page
table. However I'm running this confusing error:
peewee.OperationalError: table page__tmp__ has no column named FOREIGN
My guess is that it has something to do with the need to create an intermediary table when using sqlite.
Current Model:
Full source is here https://github.com/csytan/textmug/blob/master/db.py
class User(BaseModel):
id = peewee.CharField(primary_key=True, max_length=20)
class Page(BaseModel):
id = peewee.PrimaryKeyField()
name = peewee.TextField(unique=True, null=True)
user = peewee.ForeignKeyField(User, null=True, related_name='pages')
Migration Script:
from playhouse import migrate
my_db = migrate.SqliteDatabase('database')
migrator = migrate.SqliteMigrator(my_db)
with my_db.transaction():
migrate.migrate(
migrator.rename_column('page', 'name', 'title')
)