beckenrode / mysql-workbench-export-laravel-5-migrations

A MySQL Workbench plugin which exports a Model to Laravel 5 Migrations
MIT License
898 stars 236 forks source link

Error during "Export Laravel 5 Migration" #18

Open AFZidan opened 7 years ago

AFZidan commented 7 years ago

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 commented 7 years ago

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

RizwanAslam commented 7 years ago

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

VeeeneX commented 7 years ago

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

RizwanAslam commented 7 years ago

image

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

RizwanAslam commented 7 years ago

plz lemme know if you need more info. Thanks

VeeeneX commented 7 years ago

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

VeeeneX commented 7 years ago

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

AFZidan commented 7 years ago

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 commented 7 years ago

@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 commented 7 years ago

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

gin1314 commented 7 years ago

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 commented 7 years ago

@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 commented 7 years ago

@VeeeneX thanks! 👍 , will give it a try

VeeeneX commented 7 years ago

Fixes are in master branch, should be fixed now

IgorDePaula commented 7 years ago

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 commented 7 years ago

@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 :)

IgorDePaula commented 7 years ago

user

RizwanAslam commented 7 years ago

@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 commented 7 years ago

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 commented 7 years ago

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

beckenrode commented 7 years ago

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

arysom commented 7 years ago

Tried with latest from master. unfortunately still hangs.

beckenrode commented 7 years ago

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

wilianuhlmann commented 7 years ago

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

veganista commented 7 years ago

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 commented 7 years ago

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

VeeeneX commented 7 years ago

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

gmsergiov commented 6 years ago

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 commented 6 years ago

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

IgorDePaula commented 6 years ago

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 commented 6 years ago

@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 commented 5 years ago

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 commented 3 years ago

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 commented 3 years ago

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.