No but try this: First do a migration in which you remove the field
completely. Then do a migration in which you add the field again with
the new attributes.

Massimo

On Dec 10, 7:13 am, Maciek Sykulski <[email protected]> wrote:
> Hi,
>
> In web2py 1.72.3,
> when I change db.py from:
>
> db.define_table('report_segment' ,
>                 Field
> ('acgh_sg_id',db.acgh_segment,ondelete='CASCADE'),
>                 Field
> ('acgh_report_id',db.acgh_report,ondelete='CASCADE')
>                 )
> to:
>
> db.define_table('report_segment' ,
>                 Field('acgh_sg_id',db.acgh_segment,ondelete='SET
> NULL'),
>                 Field
> ('acgh_report_id',db.acgh_report,ondelete='CASCADE')
>                 )
> I get an error:
>
> Traceback (most recent call last):
>   File "/home/maciek/workspace/imid2py/gluon/restricted.py", line 184,
> in restricted
>     exec ccode in environment
>   File "/home/maciek/workspace/imid2py/applications/welcome/models/
> db.py", line 285, in <module>
>     Field('acgh_report_id',db.acgh_report,ondelete='CASCADE')
>   File "/home/maciek/workspace/imid2py/gluon/sql.py", line 1205, in
> define_table
>     query = t._create(migrate=migrate, fake_migrate=fake_migrate)
>   File "/home/maciek/workspace/imid2py/gluon/sql.py", line 1647, in
> _create
>     fake_migrate=fake_migrate)
>   File "/home/maciek/workspace/imid2py/gluon/sql.py", line 1701, in
> _migrate
>     self._db._execute(sub_query)
>   File "/home/maciek/workspace/imid2py/gluon/sql.py", line 879, in
> <lambda>
>     self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
>   File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 166, in
> execute
>     self.errorhandler(self, exc, value)
>   File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 35,
> in defaulterrorhandler
>     raise errorclass, errorvalue
> OperationalError: (1061, "Duplicate key name 'acgh_sg_id__idx'")
>
>  (what's interesting the error is reported in db.py in the line
> following the actual change)
>
> I observed similar errors when adding  unique=True to a table
> definition.
> Any clues?

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to