`pw_migrate migrate` fails when changing fields against Postgresql
bogdandragomirescu opened this issue · comments
Happens with peewee-migrate version 1.0.0 (tested against multiple peewee versions from the latest one (3.6.4) backwards, didn't find any where this doesn't occur).
Error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/peewee_migrate/router.py", line 144, in run_one
migrator.run()
File "/usr/local/lib/python2.7/site-packages/peewee_migrate/migrator.py", line 129, in run
op.run()
File "/usr/local/lib/python2.7/site-packages/playhouse/migrate.py", line 141, in run
self._handle_result(method(*self.args, **kwargs))
File "/usr/local/lib/python2.7/site-packages/playhouse/migrate.py", line 149, in inner
return fn(self, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/peewee_migrate/migrator.py", line 36, in change_column
operations = [self.alter_change_column(table, column_name, field)]
File "/usr/local/lib/python2.7/site-packages/peewee_migrate/migrator.py", line 81, in alter_change_column
field_clause = clause.nodes[-1]
AttributeError: 'Context' object has no attribute 'nodes'
Other details:
OS: Ubuntu 16.04
Setup: docker version 18.06.0-ce; docker-compose version 1.8.0; Python 2.7; postgresql version 9.6
Steps:
- Create model with a few fields
class PgTest(Model):
class Meta:
database = psql_client.db
table_function = lambda model_cls: '{model_name}'.format(model_name=model_cls.__name__.lower())
id = AutoField()
name = CharField(max_length=100, index=True)
-
Create migration, and migrate it
$ pw_migrate create --auto test.models --directory test/migrations --database postgresql://postgres@postgres:5432/postgres test
$ pw_migrate migrate --directory test/migrations --database postgresql://postgres@postgres:5432/datalake --name 001_test
-
Back to the model, alter
max_length
on thename
field, generate new migration -
Migrate the new migration, result is the traceback above.
Can reproduce it on PostgreSQL database with latest peewee
and peewee_migrate
.
Same for me. Is there any chance it can be fixed some time soon?
Hey yall, looks like this particular issue was fixed. I came across this issue while reporting #135. I followed the steps in the top description and the max_length
was successfully changed.
I feel like this particular issue can probably be closed.