hi,

i create table from scratch on mysql using web2py 2.7.4. on windows 7 but 
return an error :

InternalError: (1005, u"Can't create table 'testingmysql.company' (errno: 150)")

when test the same code using sqlite, no errors occured

my root cause analysis is auth_user have reference field to another table.
*
*
*code :*
*### error*
models/db.py
db = DAL('mysql://root:@localhost/testingmysqlweb2py', pool_size=1, 
check_reserved=['all'], migrate=True)

db.define_table('company',
    Field('name', notnull=True),
    Field('home', 'text', notnull=True),
    Field('about_us', 'text', notnull=True),
    Field('website', notnull=True),
    Field('trademark', 'upload', uploadfield = 'trademark_file', 
notnull=True),
    Field('trademark_file', 'blob', notnull=True),
    format='%(name)s')

db.define_table('branch',
    Field('address', 'text', notnull=True),
    Field('zip_code', notnull=True),
    Field('city', notnull=True),
    Field('country', notnull=True),
    Field('phone', 'list:string', notnull=True),
    Field('fax', 'list:string'),
    Field('email', 'list:string', notnull=True),
    Field('company', 'reference company', notnull=True),
    format='%(address)s')

auth.settings.extra_fields['auth_user']=[
    Field('gender', notnull=True),
    Field('address', 'text', notnull=True),
    Field('zip_code', notnull=True),
    Field('city', notnull=True),
    Field('country', notnull=True),
    Field('phone', 'list:string', notnull=True),
*    Field('branch', 'reference branch', notnull=True)] # root cause*

*### not error*
models/db.py
db = DAL('mysql://root:@localhost/testingmysqlweb2py', pool_size=1, 
check_reserved=['all'], migrate=True)

auth.settings.extra_fields['auth_user']=[
    Field('gender', notnull=True),
    Field('address', 'text', notnull=True),
    Field('zip_code', notnull=True),
    Field('city', notnull=True),
    Field('country', notnull=True),
    Field('phone', 'list:string', notnull=True)]

db.define_table('company',
    Field('name', notnull=True),
    Field('home', 'text', notnull=True),
    Field('about_us', 'text', notnull=True),
    Field('website', notnull=True),
    Field('trademark', 'upload', uploadfield = 'trademark_file', 
notnull=True),
    Field('trademark_file', 'blob', notnull=True),
    format='%(name)s')

db.define_table('branch',
    Field('address', 'text', notnull=True),
    Field('zip_code', notnull=True),
    Field('city', notnull=True),
    Field('country', notnull=True),
    Field('phone', 'list:string', notnull=True),
    Field('fax', 'list:string'),
    Field('email', 'list:string', notnull=True),
    Field('company', 'reference company', notnull=True),
    format='%(address)s')

my question is :
how can i create table on mysql when auth_user have reference field to 
another table?

thanks and best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to