Skip to content
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

SQLite migration bug? #380

Closed
coleifer opened this issue Jun 23, 2014 · 2 comments
Closed

SQLite migration bug? #380

coleifer opened this issue Jun 23, 2014 · 2 comments

Comments

@coleifer
Copy link
Owner

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')
    )
@passiomatic
Copy link

I can confirm the weird behavior with the testcase above and on my code too. In my case the models are similar: a Feed model and an Entry model, with the latter having a FK to Feed.

On my machine it gives this error:

peewee.OperationalError: table page__tmp__ has no column named FOREIGN

I'm using:

Underworld:$ python
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54) 
>>> import sqlite3 as s
>>> s.version
'2.6.0'
>>> s.sqlite_version
'3.7.13'

@coleifer
Copy link
Owner Author

coleifer commented Jul 9, 2014

Replicated this in a test-case, working up a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants