qizhiyi / sqlalchemy-migrate

Automatically exported from code.google.com/p/sqlalchemy-migrate
MIT License
0 stars 0 forks source link

migrate update_db_from_model fails when creating columns with default values #95

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Add a column to an SA schema with a default value
2. Run migrate update_db_from_model
3. Bails out mid-way

What is the expected output? What do you see instead?
File 
"/home/nedosa/Work/tg2env/lib/python2.6/site-packages/sqlalchemy_migrate-0.6.1.d
ev-py2.6.egg/migrate/changeset/schema.py", line 531, in create
    stmt = table.update().values({self: engine._execute_default(self.default)})
AttributeError: 'NoneType' object has no attribute 'update'

What version of the product are you using? On what operating system?
latest trunk of SA-migrate, SQ 0.5.8, MySQL 5.1.41

Please provide any additional information below.

Original issue reported on code.google.com by ned...@gmail.com on 31 Aug 2010 at 9:35

GoogleCodeExporter commented 8 years ago
Has this ever been fixed ?

Original comment by Romy.Max...@gmail.com on 17 Dec 2010 at 6:28

GoogleCodeExporter commented 8 years ago
This is still reproducable with migrate 0.7.1 and sqlalchemy 0.7.2

Original comment by vierzigu...@gmail.com on 23 Sep 2011 at 3:41

GoogleCodeExporter commented 8 years ago
it would be great to get a full backtrace (add import pdb; pdb.set_trace() just 
before the offending line in migrate/changeset/schema.py). I assume this is not 
fixed in current mercurial versions.

Original comment by jan.ditt...@gmail.com on 28 Oct 2011 at 10:06

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Attachment is on a correction suggestion.

full backtrace below, using pdb:

> 
/opt/users/pvictorino/workspace/ariane/catalogo/install/lib/python2.5/site-packa
ges/sqlalchemy_migrate-0.7.2-py2.5.egg/migrate/changeset/schema.py(534)create()
-> stmt = table.update().values({self: engine._execute_default(self.default)})
(Pdb) bt
  /opt/users/pvictorino/workspace/ariane/catalogo/sandbox/inpe/mster/mster/schema/mster.py(5)<module>()
-> main(url='mysql://root@localhost/mster', debug='False', repository='manager')
  /opt/users/pvictorino/workspace/ariane/catalogo/install/lib/python2.5/site-packages/sqlalchemy_migrate-0.7.2-py2.5.egg/migrate/versioning/shell.py(207)main()
-> ret = command_func(**kwargs)
  /opt/users/pvictorino/workspace/ariane/catalogo/install/lib/python2.5/site-packages/sqlalchemy_migrate-0.7.2-py2.5.egg/migrate/versioning/api.py(186)upgrade()
-> return _migrate(url, repository, version, upgrade=True, err=err, **opts)
  <string>(2)_migrate()
  /opt/users/pvictorino/workspace/ariane/catalogo/install/lib/python2.5/site-packages/sqlalchemy_migrate-0.7.2-py2.5.egg/migrate/versioning/util/__init__.py(159)with_engine()
-> return f(*a, **kw)
  /opt/users/pvictorino/workspace/ariane/catalogo/install/lib/python2.5/site-packages/sqlalchemy_migrate-0.7.2-py2.5.egg/migrate/versioning/api.py(366)_migrate()
-> schema.runchange(ver, change, changeset.step)
  /opt/users/pvictorino/workspace/ariane/catalogo/install/lib/python2.5/site-packages/sqlalchemy_migrate-0.7.2-py2.5.egg/migrate/versioning/schema.py(91)runchange()
-> change.run(self.engine, step)
  /opt/users/pvictorino/workspace/ariane/catalogo/install/lib/python2.5/site-packages/sqlalchemy_migrate-0.7.2-py2.5.egg/migrate/versioning/script/py.py(145)run()
-> script_func(engine)
  /opt/users/pvictorino/workspace/ariane/catalogo/sandbox/inpe/mster/mster/schema/manager/versions/003_alter_table_job_add.py(37)upgrade()
-> post_meta.tables['job'].columns['debug'].create()
> 
/opt/users/pvictorino/workspace/ariane/catalogo/install/lib/python2.5/site-packa
ges/sqlalchemy_migrate-0.7.2-py2.5.egg/migrate/changeset/schema.py(534)create()
-> stmt = table.update().values({self: engine._execute_default(self.default)})

Original comment by lau...@gmail.com on 2 Dec 2011 at 3:17

Attachments:

GoogleCodeExporter commented 8 years ago
My current workaround:

    table.c.column.create(table=table)

Original comment by ento.ent...@gmail.com on 27 Jun 2012 at 2:49