MySQL problem

54 views
Skip to first unread message

Alfonso de la Guarda

unread,
Oct 22, 2013, 2:14:22 PM10/22/13
to web...@googlegroups.com
Hi,

For the first time i have found a problem between web2py and mysql in
two Linux flavors: Ubuntu and Arch.

When i try to simply change the database from sqlite to mysql (and
after delete all inside databases) the mysql shows me an error:

<class '_mysql_exceptions.OperationalError'> (1005, "Can't create
table 'bassistant.auth_user' (errno: 150)")

Obviosuly my ba-users has the right permissions, but when i check for
the log in databases i notice this:


CREATE TABLE auth_user(
id INT AUTO_INCREMENT NOT NULL,
first_name VARCHAR(128),
last_name VARCHAR(128),
email VARCHAR(512),
password VARCHAR(512),
registration_key VARCHAR(512),
reset_password_key VARCHAR(512),
registration_id VARCHAR(512),
phone VARCHAR(512),
company INT, INDEX company__idx (company), FOREIGN KEY (company)
REFERENCES companies (id) ON DELETE CASCADE,
place INT, INDEX place__idx (place), FOREIGN KEY (place)
REFERENCES places (id) ON DELETE CASCADE,
PRIMARY KEY(id)
) ENGINE=InnoDB CHARACTER SET utf8;

Which references to foreign keys which obviously aren't created yet,
also in Arch i am using MariaDB (which doesn't uses InnoDB) with the
same driver.

Any consideration for this? If not i will try to fix in the dal source
and put the changes.


Saludos,

--------------------------------
Alfonso de la Guarda
Twitter: @alfonsodg
Redes sociales: alfonsodg
Telef. 991935157
1024D/B23B24A4
5469 ED92 75A3 BBDB FD6B 58A5 54A1 851D B23B 24A4

Cliff Kachinske

unread,
Oct 22, 2013, 4:45:02 PM10/22/13
to web...@googlegroups.com
Are you using lazy tables?

Do your models define the referenced tables before they define the referrer?

Alfonso de la Guarda

unread,
Oct 23, 2013, 8:50:39 AM10/23/13
to web...@googlegroups.com
Hi,

The problem is in the auth custom fields because they are created
before any other table and the extra fields add some relations. At
first time, i need create the basic auth table and after that just add
the extra fields, then for the deployment is a 2 step process.
Maybe the extra fileds should be created after the other tables.
Saludos,

--------------------------------
Alfonso de la Guarda
Twitter: @alfonsodg
Redes sociales: alfonsodg
Telef. 991935157
1024D/B23B24A4
5469 ED92 75A3 BBDB FD6B 58A5 54A1 851D B23B 24A4


> --
> 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+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Cliff Kachinske

unread,
Oct 23, 2013, 2:54:19 PM10/23/13
to web...@googlegroups.com
You can always define other tables before the call to auth.define_tables().

Unless they have dependencies on other auth_* tables, that is.

Alfonso de la Guarda

unread,
Oct 23, 2013, 3:37:05 PM10/23/13
to web...@googlegroups.com
Hi,

Yes, i know.... howver auth_user has previous dependencies from
another tables and those tables also between them, the solution will
be simply define extra fields at the final of table definitions inside
db.py
Saludos,

--------------------------------
Alfonso de la Guarda
Twitter: @alfonsodg
Redes sociales: alfonsodg
Telef. 991935157
1024D/B23B24A4
5469 ED92 75A3 BBDB FD6B 58A5 54A1 851D B23B 24A4


Reply all
Reply to author
Forward
0 new messages