Hi Dave, Thanks for your reply. When starting web2py again the DAL tries to create the tables but none of the tables are being created due to this error. Using a clean new version of a web2py app the tables are created and are of type innodb storage engine( as mentioned in the page you sent).
I am still no step further with solving this issue. Steve Op woensdag 11 september 2019 10:35:22 UTC+2 schreef Dave S: > > > > On Tuesday, September 10, 2019 at 2:58:06 PM UTC-7, Steve wrote: >> >> Goodevening, >> >> I am trying to migrate from Sqite to MySQL. >> Unfortunatly when restoring the field in the DB tables i get the >> following error: >> <class 'gluon.contrib.pymysql.err.IntegrityError'> (1215, u'Cannot add >> foreign key constraint') >> location of issue: Field('Insurance',db.insurance,label=T('Insurance')), >> >> When i look this up in google .... this could be caused by a Field which >> has the reuirement= Not NULL but has no Default value set. >> I tested this but not able to get passed the error. >> >> *first table with field in db1.py* >> >> db.define_table('insurance', >> >> Field('Company',requires=IS_NOT_EMPTY(error_message='cannot be empty!'), >> label=T('Company')), >> Field('Insurance_number','string', >> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), >> label=T('Insurance Number')), >> Field('Street_name', >> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('Street >> Name')), >> Field('House_number','string', >> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('House >> Number')), >> Field('Postal_code','string', >> requires=IS_NOT_EMPTY(error_message='cannot be empty!'),label=T('Postal >> Code')), >> Field('City','string', >> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('City')), >> Field('Region','string', >> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('Region')), >> Field('Country','string', >> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), >> label=T('Country')), >> Field('Telephone_number','string', >> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('Telephone >> Number')), >> Field('Mobile','string', >> requires=IS_NOT_EMPTY(error_message='cannot be empty!'), label=T('Mobile')), >> Field('Email','string', >> requires=IS_EMAIL(error_message='invalid email! Please fill in a correct >> e-mail address.'), label=T('Email')), >> auth.signature, format='%(Company)s',fake_migrate=True) >> >> *Second table which in a db2.py:* >> >> db.define_table('client', >> >> Field('Debtor_nr',requires=IS_NOT_EMPTY(error_message='cannot be empty!'), >> label=T('Debtor number')), >> Field('Insurance',db.insurance,label=T('Insurance')), --> >> this >> is where the first issue takes place >> >> Where should i add a default value ? to et this issue fixed >> >> Hope you can help me with this >> >> Steve >> > > This page has different diagnoses than you mention: > <URL: > https://www.rathishkumar.in/2016/01/solved-how-to-solve-mysql-error-code.html > > > > There, the issue with NULL is that the foreign key can't be NULL if it is > part of the child table's primary key. > > Another way to get the error is to use a different mysql storage engine > than innodb. > > Yet another way is to not have a unique key in the table, but since you're > using a model file to describe the parent table, the DAL should have > handled that, and also made sure that the parent and child agree on what > the key is. > > As a first step, use your mysql console or dbclient to display the schema > used for the insurance table. (I can't tell you how to do that, because > I use sqlite and postgres, not mysql, so I know two incantations but they > probably don't match what you need). > > Good luck! > > /dps > > > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/2e2fc51b-5120-47e6-99a8-dd0fbca276a4%40googlegroups.com.