Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during "Export Laravel 5 Migration" #18

Open
AFZidan opened this issue Nov 18, 2016 · 34 comments
Open

Error during "Export Laravel 5 Migration" #18

AFZidan opened this issue Nov 18, 2016 · 34 comments
Labels

Comments

@AFZidan
Copy link

AFZidan commented Nov 18, 2016

I installed this plugin as described in documentation file .
I tried to export my database using

tools->catalog->export laravel 5 migration
screenshot from 2016-11-19 01-12-34

but it's showing error
error calling Python module function GenerateLaravel5Migration.generate_laravel5_migration

@beckenrode
Copy link
Owner

Would you be able to share your model to help diagnose this?

@RizwanAslam
Copy link

Same error on windows too +1
I have tried many different databases. The error is same.

@VeeeneX
Copy link
Collaborator

VeeeneX commented Nov 19, 2016

@ahmedfathi1 Which version do you have? Latest from master?

@RizwanAslam
Copy link

image

You can see here, its is the latest from master.
and this is my workbench v
image

@RizwanAslam
Copy link

plz lemme know if you need more info.
Thanks

@VeeeneX
Copy link
Collaborator

VeeeneX commented Nov 19, 2016

@RizwanAslam I tested it, can you please post a log? Please show us the log, Help > Show Log File

@VeeeneX
Copy link
Collaborator

VeeeneX commented Nov 19, 2016

I tested in on latest version of Workbench 6.3 CE on Windows and it works. Just post log files.

@AFZidan
Copy link
Author

AFZidan commented Nov 20, 2016

I'm using version latest from master... and Workbench V.6.3 on linux (ubuntu 16.04)

I tested it on different databases

My log file :

07:13:25 [INF][ WBContext]: Parsing application arguments.
07:13:25 [INF][ WBContext]: /usr/lib/mysql-workbench/mysql-workbench-bin
07:13:25 [INF][ WBContext UI]: Initializing workbench context UI with these values:
base dir: /usr/share/mysql-workbench
plugin path: /usr/lib/mysql-workbench/plugins
struct path: /usr/share/mysql-workbench/grt
module path: /usr/lib/mysql-workbench/modules
library path: /usr/share/mysql-workbench/libraries
user data dir: /home/ahmed/.mysql/workbench
open at start:
open type:
run at startup:
run type:
Force SW rendering: No
Force OpenGL: No
quit when done: No
07:13:25 [INF][ WBContext]: WbContext::init
07:13:26 [INF][ WBA]: Looking for extension modules for WBA...
07:13:26 [INF][ WBA]: 0 extension modules found
07:13:26 [WRN][ grt]: /usr/share/mysql-workbench/data/table_templates.xml:21: link 'com.mysql.rdbms.mysql.datatype.timestamp' key=simpleType could not be resolved
07:13:26 [WRN][ grt]: /usr/share/mysql-workbench/data/table_templates.xml:106: link 'com.mysql.rdbms.mysql.datatype.varchar' key=simpleType could not be resolved
07:13:26 [WRN][ grt]: /usr/share/mysql-workbench/data/table_templates.xml:229: link 'com.mysql.rdbms.mysql.datatype.int' key=simpleType could not be resolved
07:13:26 [WRN][ grt]: /home/ahmed/.mysql/workbench/connections.xml:15: link 'e7b911d0-aeda-11e6-9c9f-8056f2373acb' key=owner could not be resolved
07:13:26 [INF][ WBContext]: System info:
MySQL Workbench Community (GPL) for Linux/Unix version 6.3.6 CE build 511 (64 bit)
Configuration Directory: /home/ahmed/.mysql/workbench
Data Directory: /usr/share/mysql-workbench
Cairo Version: 1.14.6
OS: Linux 4.4.0-47-generic
CPU: 4x Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz (2524.789MHz) - 7.69GiB RAM
Distribution: Ubuntu 16.04.1 LTS

Fips mode enabled: no

07:14:50 [ERR][ GRTDispatcher]: exception in grt execute_task, continuing: Exception: Access denied for user 'root'@'localhost' (using password: NO)
07:14:50 [ERR][ GRTDispatcher]: worker: task 'execute sql queries' has failed with error:.Access denied for user 'root'@'localhost' (using password: NO)
07:14:52 [INF][ WQE backend]: User cancelled connection
07:14:52 [INF][ WBContext]: Connection to Local instance 3306 cancelled by user: Cancelled
07:15:03 [ERR][ python]: error calling GenerateLaravel5Migration.generate_laravel5_migrationTraceback (most recent call last):
07:15:03 [ERR][ python]: File "/home/ahmed/.mysql/workbench/modules/export-laravel-5-migrations_grt.py", line 408, in generate_laravel5_migration
07:15:03 [ERR][ python]: migrations = export_schema(schema[0], table_tree)
07:15:03 [ERR][ python]: File "/home/ahmed/.mysql/workbench/modules/export-laravel-5-migrations_grt.py", line 320, in export_schema
07:15:03 [ERR][ python]: index_name = key.index.name
07:15:03 [ERR][ python]: AttributeError: 'NoneType' object has no attribute 'name'
07:15:03 [ERR][ grt]: Error executing plugin wb.util.generate_laravel5_migration: error calling Python module function GenerateLaravel5Migration.generate_laravel5_migration
07:15:03 [ERR][ WBContext]: error calling Python module function GenerateLaravel5Migration.generate_laravel5_migration

@beckenrode
Copy link
Owner

@ahmedfathi1 It appears that the error is caused by a missing index.name on a foreign key, though I'm unsure why as of now. Please pull the latest from master and let us know if it works now.

@AFZidan
Copy link
Author

AFZidan commented Nov 20, 2016

@beckenrode Excellent... It's working now
Thank you so much ..

@gin1314
Copy link

gin1314 commented Nov 20, 2016

hi, im having the same issue, im using Mac OS X 10.11.6, MySQL Workbench Community (GPL) for Mac OS X version 6.3.6 CE build 511 (32 bit)

19:48:28 [ERR][ python]: error calling GenerateLaravel5Migration.generate_laravel5_migrationTraceback (most recent call last):
19:48:28 [ERR][ python]: File "/Users/eugene/Library/Application Support/MySQL/Workbench/modules/export-laravel-5-migrations_grt.py", line 408, in generate_laravel5_migration
19:48:28 [ERR][ python]: migrations = export_schema(schema[0], table_tree)
19:48:28 [ERR][ python]: File "/Users/eugene/Library/Application Support/MySQL/Workbench/modules/export-laravel-5-migrations_grt.py", line 228, in export_schema
19:48:28 [ERR][ python]: primary_col = primary_key.columns[0].referencedColumn
19:48:28 [ERR][ python]: AttributeError: 'NoneType' object has no attribute 'columns'
19:48:28 [ERR][ grt]: Error executing plugin wb.util.generate_laravel5_migration: error calling Python module function GenerateLaravel5Migration.generate_laravel5_migration
19:48:28 [ERR][ WBContext]: error calling Python module function GenerateLaravel5Migration.generate_laravel5_migration

VeeeneX added a commit to VeeeneX/mysql-workbench-export-laravel-5-migrations that referenced this issue Nov 20, 2016
- Added testing Model
- Fix for beckenrode#18
- Fixed issues with 'CURRENT_TIMESTAMP', 'NULL ON UPDATE CURRENT_TIMESTAMP',  'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'
- Check for non existing column types
- Fixed index keys, primary key is no longer included
- Added .gitignore
VeeeneX added a commit to VeeeneX/mysql-workbench-export-laravel-5-migrations that referenced this issue Nov 20, 2016
- Added testing Model
- Fix for beckenrode#18
- Fixed issues with 'CURRENT_TIMESTAMP', 'NULL ON UPDATE CURRENT_TIMESTAMP',  'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'
- Check for non existing column types
- Fixed index keys, primary key is no longer included
- Added .gitignore
@VeeeneX
Copy link
Collaborator

VeeeneX commented Nov 20, 2016

@gin1314 You can test this fork https://github.com/VeeeneX/mysql-workbench-export-laravel-5-migrations, until it gets merged.
@beckenrode I created a new PR with some new features and fix for @gin1314's issue

@gin1314
Copy link

gin1314 commented Nov 20, 2016

@VeeeneX thanks! 👍 , will give it a try

@VeeeneX VeeeneX added the bug label Nov 20, 2016
VeeeneX added a commit that referenced this issue Nov 20, 2016
* Updates

- Added testing Model
- Fix for #18
- Fixed issues with 'CURRENT_TIMESTAMP', 'NULL ON UPDATE CURRENT_TIMESTAMP',  'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'
- Check for non existing column types
- Fixed index keys, primary key is no longer included
- Added .gitignore
@VeeeneX
Copy link
Collaborator

VeeeneX commented Nov 20, 2016

Fixes are in master branch, should be fixed now

@VeeeneX VeeeneX closed this as completed Nov 20, 2016
@IgorDePaula
Copy link

I received the same error, workbench 6.3 (6.3.4.9 build828 64bits), ubuntu 15.10

14:47:43 [INF][      WBContext]:     /usr/lib/mysql-workbench/mysql-workbench-bin
14:47:43 [INF][   WBContext UI]: Initializing workbench context UI with these values:
	base dir: /usr/share/mysql-workbench
	plugin path: /usr/lib/mysql-workbench/plugins
	struct path: /usr/share/mysql-workbench/grt
	module path: /usr/lib/mysql-workbench/modules
	library path: /usr/share/mysql-workbench/libraries
	user data dir: /home/igor/.mysql/workbench
	open at start: 
	open type: 
	run at startup: 
	run type: 
	Force SW rendering: No
	Force OpenGL: No
	quit when done: No
14:47:43 [INF][      WBContext]: WbContext::init
14:47:43 [INF][            WBA]: Looking for extension modules for WBA...
14:47:43 [INF][            WBA]: 0 extension modules found
14:47:43 [WRN][            grt]: /usr/share/mysql-workbench/data/table_templates.xml:21: link 'com.mysql.rdbms.mysql.datatype.timestamp' <object db.SimpleDatatype> key=simpleType could not be resolved
14:47:43 [WRN][            grt]: /usr/share/mysql-workbench/data/table_templates.xml:106: link 'com.mysql.rdbms.mysql.datatype.varchar' <object db.SimpleDatatype> key=simpleType could not be resolved
14:47:43 [WRN][            grt]: /usr/share/mysql-workbench/data/table_templates.xml:229: link 'com.mysql.rdbms.mysql.datatype.int' <object db.SimpleDatatype> key=simpleType could not be resolved
14:47:43 [WRN][            grt]: /home/igor/.mysql/workbench/connections.xml:26: link '287f4c5d-b00a-11e6-8041-204747fcf697' <object GrtObject> key=owner could not be resolved
14:47:43 [INF][      WBContext]: System info:
 	MySQL Workbench Community (GPL) for Linux/Unix version 6.3.4  revision 0 build 828 (64 bit)
	Configuration Directory: /home/igor/.mysql/workbench
	Data Directory: /usr/share/mysql-workbench
	Cairo Version: 1.14.2
	OS: Linux 4.2.0-42-generic
	CPU: 4x Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz (2899.968MHz) - 7,71GiB RAM
	Distribution: Ubuntu 15.10

	Fips mode enabled: no

14:47:52 [ERR][         python]: error calling GenerateLaravel5Migration.generate_laravel5_migrationTraceback (most recent call last):
14:47:52 [ERR][         python]:   File "/home/igor/.mysql/workbench/modules/export-laravel-5-migrations2_grt.py", line 425, in generate_laravel5_migration
14:47:52 [ERR][         python]:     table_tree = create_tree(schema[0])
14:47:52 [ERR][         python]:   File "/home/igor/.mysql/workbench/modules/export-laravel-5-migrations2_grt.py", line 150, in create_tree
14:47:52 [ERR][         python]:     table_references.append(key.referencedColumns[0].owner.name)
14:47:52 [ERR][         python]: IndexError: list index out of range
14:47:52 [ERR][            grt]: Error executing plugin wb.util.generate_laravel5_migration: error calling Python module function GenerateLaravel5Migration.generate_laravel5_migration	
14:47:52 [ERR][      WBContext]: error calling Python module function GenerateLaravel5Migration.generate_laravel5_migration```

@VeeeneX
Copy link
Collaborator

VeeeneX commented Nov 21, 2016

@IgorDePaula Thanks for pointing out this issue, is it possible to show your model or give some kind of example of model so we can prevent this bug in future I will create a hot fix for this :)

@VeeeneX VeeeneX reopened this Nov 21, 2016
@IgorDePaula
Copy link

user

@RizwanAslam
Copy link

@VeeeneX Sorry for late reply.
This is Workbench Log just after this error.

13:55:20 [INF][ SqlEditor]: Opened connection 'Local instance wampmysqld64' to MySQL Community Server (GPL) version 5.7.11
13:55:21 [INF][ AutoCCache]: Initializing autocompletion cache for Local_instance_wampmysqld64
13:55:21 [INF][ WQE.net]: Launching SQL IDE
13:55:21 [INF][ WQE.net]: SQL IDE UI is ready
13:56:11 [INF][ grt]: Fetching schema list.
13:56:11 [INF][ grt]: OK
13:56:26 [INF][ grt]: Fetching table list.
13:56:26 [INF][ grt]: 21 items from mailtrain
13:56:26 [INF][ grt]: 18 items from vendroid
13:56:26 [INF][ grt]: OK
13:56:26 [INF][ grt]: Fetching view list.
13:56:26 [INF][ grt]: 0 items from mailtrain
13:56:26 [INF][ grt]: 0 items from vendroid
13:56:26 [INF][ grt]: OK
13:56:26 [INF][ grt]: Fetching routine list.
13:56:26 [INF][ grt]: 0 items from mailtrain
13:56:26 [INF][ grt]: 0 items from vendroid
13:56:26 [INF][ grt]: OK
13:56:26 [INF][ grt]: Fetching trigger list.
13:56:26 [INF][ grt]: 0 items from mailtrain
13:56:26 [INF][ grt]: 0 items from vendroid
13:56:26 [INF][ grt]: OK
13:56:31 [INF][ Canvas backend]: Found OpenGL version for this view: 4.3.0 - Build 10.18.15.4248
13:56:43 [ERR][ python]: error calling GenerateLaravel5Migration.generate_laravel5_migrationTraceback (most recent call last):
13:56:43 [ERR][ python]: File "C:\Users\huuul\AppData\Roaming\MySQL\Workbench\modules\export-laravel-5-migrations_grt.py", line 408, in generate_laravel5_migration
13:56:43 [ERR][ python]: migrations = export_schema(schema[0], table_tree)
13:56:43 [ERR][ python]: File "C:\Users\huuul\AppData\Roaming\MySQL\Workbench\modules\export-laravel-5-migrations_grt.py", line 228, in export_schema
13:56:43 [ERR][ python]: primary_col = primary_key.columns[0].referencedColumn
13:56:43 [ERR][ python]: AttributeError: 'NoneType' object has no attribute 'columns'
13:56:43 [ERR][ grt]: Error executing plugin wb.util.generate_laravel5_migration: error calling Python module function GenerateLaravel5Migration.generate_laravel5_migration
13:56:43 [ERR][ WBContext]: error calling Python module function GenerateLaravel5Migration.generate_laravel5_migration

@arysom
Copy link

arysom commented Nov 22, 2016

Xampp on mac, model with foreign keys, workbench freezes unfortunatelly. MySQL Workbench Community (GPL) for Mac OS X version 6.3.6 CE build 511 (32 bit).

@beckenrode
Copy link
Owner

@arysom Please try the latest from master as this sounds like it is related to #21

beckenrode added a commit that referenced this issue Nov 24, 2016
Check if referencedColumns exists
@beckenrode
Copy link
Owner

@IgorDePaula Please try the latest from master to see if it solves this problem.

@arysom
Copy link

arysom commented Nov 24, 2016

Tried with latest from master. unfortunately still hangs.

@beckenrode
Copy link
Owner

@arysom could you share your log file and/or your model so that this can be further looked into?

@wilianuhlmann
Copy link

wilianuhlmann commented Nov 29, 2016

I'm using it normally.
SO: Windows 10 PRO 64x
Workbench 6.3 64x

@veganista
Copy link

I just got a very similar issue to this, by stripping back my tables i realised that i had one on my model that was not on my EER diagram that wasn't properly set up. i.e i hadn't selected the column types, so i was getting this error in my log:

12:27:37 [ERR][      WBContext]: error calling Python module function GenerateLaravel5Migration.generate_laravel5_migration
12:30:39 [ERR][         python]: error calling GenerateLaravel5Migration.generate_laravel5_migration
Traceback (most recent call last):
12:30:39 [ERR][         python]:   File "[...]/Library/Application Support/MySQL/Workbench/modules/export-laravel-5-migrations_grt.py", line 432, in generate_laravel5_migration
12:30:39 [ERR][         python]:     
12:30:39 [ERR][         python]:   File "[...]/Library/Application Support/MySQL/Workbench/modules/export-laravel-5-migrations_grt.py", line 251, in export_schema
12:30:39 [ERR][         python]:     
12:30:39 [ERR][         python]: AttributeError: 'NoneType' object has no attribute 'name'
12:30:39 [ERR][            grt]: Error executing plugin wb.util.generate_laravel5_migration: error calling Python module function GenerateLaravel5Migration.generate_laravel5_migration

@shanginn
Copy link

shanginn commented Feb 1, 2017

also be aware of FULLTEXT indexes: they also can't be proceeded

@VeeeneX
Copy link
Collaborator

VeeeneX commented Feb 20, 2017

@veganista It's hard to tell where the issue is can you post your model?

VeeeneX added a commit that referenced this issue Feb 20, 2017
* Updates

- Added testing Model
- Fix for #18
- Fixed issues with 'CURRENT_TIMESTAMP', 'NULL ON UPDATE CURRENT_TIMESTAMP',  'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'
- Check for non existing column types
- Fixed index keys, primary key is no longer included
- Added .gitignore

* Updates

- Added testing Model
- Fix for #18
- Fixed issues with 'CURRENT_TIMESTAMP', 'NULL ON UPDATE CURRENT_TIMESTAMP',  'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'
- Check for non existing column types
- Fixed index keys, primary key is no longer included
- Added .gitignore

* Fix for #30

And possible for padding as well as small fixes
@gmsergiov
Copy link

I am also getting the same issue. I know my model is messed up but still having a log will help us to identify the failing table and column.
My current log prints the following message.

line 391, in export_schema
01:37:59 [ERR][ python]: foreign_key = key.columns[0].name

i tried to add logs myself but of curse i know nothing about phyton :(

@IgorDePaula
Copy link

@beckenrode I tried the plugin today again, continue fails... =/

@IgorDePaula
Copy link

I received this message:

Copied module /home/igor/Downloads/mysql-workbench-export-laravel-5-migrations-master/export-laravel-5-migrations.py to '/home/igor/.mysql/workbench/modules/export-laravel-5-migrations_grt.py'
Please restart Workbench for the change to take effect.
Traceback (most recent call last):
  File "/home/igor/.mysql/workbench/modules/export-laravel-5-migrations2_grt.py", line 425, in generate_laravel5_migration
    table_tree = create_tree(schema[0])
  File "/home/igor/.mysql/workbench/modules/export-laravel-5-migrations2_grt.py", line 150, in create_tree
    table_references.append(key.referencedColumns[0].owner.name)
IndexError: list index out of range
Executing script /home/igor/Downloads/mysql-workbench-export-laravel-5-migrations-master/export-laravel-5-migrations.py...

Script finished.

@matijaboban
Copy link

@beckenrode I can confirm that the issue is caused by having a fulltext index in the model. Removing it does the trick and migration get's generated.

On a side note, are there any plans to include the triggers and associated scripts into the export?

@namelus
Copy link

namelus commented Mar 27, 2019

Hi I'm having a similar issue when trying to run the plugin.

image

Workbench Version: 8.0.14
Windows 10 Home
MySQL 8

Here's my model:
image

And the log file entries:

13:19:04 [ERR][SQL Editor Form]: Unable to create db_mgmt_SSHConnectionRef object
13:19:04 [ERR][SQL Editor Form]: Unable to create db_mgmt_SSHConnectionRef object
13:19:06 [INF][ Canvas backend]: Found OpenGL version for this view: 4.4.0 - Build 21.20.16.4550
13:19:13 [ERR][         python]: error calling GenerateLaravel5Migration.generate_laravel5_migrationTraceback (most recent call last):
13:19:13 [ERR][         python]:   File "C:\Users\ayahi\AppData\Roaming\MySQL\Workbench\modules\export-laravel-5-migrations_grt.py", line 508, in generate_laravel5_migration
13:19:13 [ERR][         python]:     for name in sorted(migrations):
13:19:13 [ERR][         python]: TypeError: 'NoneType' object is not iterable
13:19:13 [ERR][            grt]: Error executing plugin wb.util.generate_laravel5_migration: error calling Python module function GenerateLaravel5Migration.generate_laravel5_migration	
13:19:13 [ERR][      WBContext]: error calling Python module function GenerateLaravel5Migration.generate_laravel5_migration

@bernatdelgado87
Copy link

Hi I'm having a similar issue when trying to run the plugin.

image

Workbench Version: 8.0.14
Windows 10 Home
MySQL 8

Here's my model:
image

And the log file entries:

13:19:04 [ERR][SQL Editor Form]: Unable to create db_mgmt_SSHConnectionRef object
13:19:04 [ERR][SQL Editor Form]: Unable to create db_mgmt_SSHConnectionRef object
13:19:06 [INF][ Canvas backend]: Found OpenGL version for this view: 4.4.0 - Build 21.20.16.4550
13:19:13 [ERR][         python]: error calling GenerateLaravel5Migration.generate_laravel5_migrationTraceback (most recent call last):
13:19:13 [ERR][         python]:   File "C:\Users\ayahi\AppData\Roaming\MySQL\Workbench\modules\export-laravel-5-migrations_grt.py", line 508, in generate_laravel5_migration
13:19:13 [ERR][         python]:     for name in sorted(migrations):
13:19:13 [ERR][         python]: TypeError: 'NoneType' object is not iterable
13:19:13 [ERR][            grt]: Error executing plugin wb.util.generate_laravel5_migration: error calling Python module function GenerateLaravel5Migration.generate_laravel5_migration	
13:19:13 [ERR][      WBContext]: error calling Python module function GenerateLaravel5Migration.generate_laravel5_migration

did you find any solution?

@smueller-maxtongroup
Copy link

In case others have an issue - I also ran into the same error @namelus and others reported.

TLDR;
Removing foreign keys with unmatched tables resolved the issue for me.

I discovered MySQL WB created foreign keys that didn't have corresponding tables. When I created my tables, I used the dropper tool to select the columns to create the relationships. Initially they were non-identifying relationships, then I changed them to identifying relationships.

In troubleshooting this issue, I looked at the table properties in the Model tab and I saw one set of relationships that corresponded properly to tables and one set that didn't have tables matched to them.

When I removed the unmatched relationships, the migration files were generated properly with the expected foreign keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests