0 votes

When I import a Laravel/Eloquent ORM through a connection to MySQL, the entities all list the fields in alphabetical order instead of the order in which the fields are listed in the actual DB table. Is there a way to achieve this with the current version? If not, I'd like to make that a feature request.

Thanks,
Stephen Dukes

in Solved by (260 points)
recategorized by

Hello, this is very strange. This is definitely not our intention and we're not aware of this. We will check it tomorrow.

In that case, here are some specifics that may help in troubleshooting:

  • Skipper and MySQL both running on MacOS Monterey 12.2.1 ARM64
  • Steps to recreate:

    • Import existing project
    • Select ORM Framework: Laravel Eloquent
    • Select MVC Framework: Laravel
    • Select External Source: Database
    • Select Database Engine: MySQL
    • Enter Database connection settings: localhost:3306

Let me know if you need any additional information.

Thanks,

Thanks, I will definitely let you know.

No need to respond, but I remembered something that might be helpful and I wanted to confirm before writing you. I did this exact same import in a previous version of Skipper and it left the fields in table order; so, this issue was introduced in the last maybe 6 months...maybe more.

Thanks again,

Hi,
just testing MySQL import and everything works as expected. We are not able to replicate the issue you're describing.

enter image description here

Can you please try to import it from a different (non ARM64 apple) MYSQL? Not sure if this issue isn't somehow bound to MySQL on ARM64.

Unfortunately we don't have any ARM Apple here for test.

Did you try it with all empty tables? When I first reported this, it was from an import of a DB where all the tables were empty. This resulted in the fields being in alphabetical order. I loaded three of the tables with data and on the next import, the fields for all tables were in table order. I deleted out all the tables and reloaded the structure only from a dump file, ran the import again, and the fields were again in alphabetical order. So, it looks like the behavior only occurs if all tables are empty.

Thanks as always for looking into this,
Stephen

Oh, ok.

So you are not importing the new project, you're importing an existing one. You didn't mention that in the original post and I overlooked that in your comment.

I'm not sure if/how this works in case, I have to check that. But is there any reason to do that?

Because this re-import never works 100% correctly (because only new tables/fields are added but nothing is removed).

It's better to import it entirely as a new project.

Correct. My steps were:

Import existing project
Select ORM Framework: Laravel Eloquent
Select MVC Framework: Laravel
Select External Source: Database
Select Database Engine: MySQL
Enter Database connection settings: localhost:3306

However, I'm all set. The workaround is simple enough. I have many projects to import. I have legacy Laravel instances to which I often need to add tables, fields, and relationships. I'm working on having an imported Skipper project for each. The dev, test, and prod instances for each project are on servers where MySQL can only be accessed externally through an SSH tunnel. Skipper doesn't have the option to specify an SSH tunnel; so, I'm dumping the structure, loading a local MySQL instance, and then importing into Skipper. Now that I know I need to load at least one table before running the ORM import, I'm good to go.

Thanks again,
Stephen

Thanks for the details, but still I don't understand why you are importing to an existing project.

Why you didn't create a new project directly from MySQL import.

Regarding SSH, we already tried that but unfortunately MySQL library doesn't support that and we didn't find reliable multi-platform solution for that ;-(

I'm confused as well, and maybe I'm missing a feature. To my understanding, I AM creating a new Skipper project. I start the project by clicking the "Import existing project" button from the home screen, do the MySql import, select the filesystem location for the new project, and when I'm done, there is a new project listed with the tables from the import. The only issue was that when all tables are empty, the import results in all the entities listing fields in alphabetical order.

Are you saying it's better to "Create a new project" and then import into that project? I figured doing it all in one operation was better....

On the SSH tunnel, I've used Navicat since the late 90s ( https://www.navicat.com/en/products/navicat-for-mysql ). It runs on all platforms and allows DB connections using an SSH tunnel. Maybe there is a way to collaborate with them? However, even without the SSH tunnel, Skipper is an awesome product.

I've also used this product for SSH tunneling on Windows: https://persistentssh.com

Skipper Get Started

ok, sorry for the confusion. You're doing that completely right. I thought you were importing it to an already created project.

But then I don't understand what you mean by "all tables are empty". Do you mean DB tables and empty as there are no records (only DQL structures imported)?

This should have no impact on import because Skipper queries only database structures, no data.

So what exactly did you mean by this?

Now that I know I need to load at least one table before running the ORM import, I'm good to go.

Because of that sentence, I thought you were creating a new empty project and then importing MySQL to the existing one. (my bad).

But now I still don't understand what do the difference between correctly ordered fields and alphabetically ordered fields.

But then I don't understand what you mean by "all tables are empty". Do you mean DB tables and empty as there are no records (only DQL structures imported)?

Yes, that is what I mean. I did a STRUCTURE-ONLY dump of the tables on my SSH-Only-Accessible server; Imported the dump file creating a local MySQL database with tables all of which contain no data. When I run the ORM Import on this database, the resulting Skipper project has the fields listed in alphabetical order for all tables (NOT in the order they appear in the actual MySQL table). When I load data into just one of the tables and re-run the import, the resulting Skipper project has all fields in the original table-order as expected. So, the workaround for my initial issue is to simply load at least one table with data before running the ORM Import.

Ok...seems that there is more to it than just the tables being empty. I ran the same procedure on a different DB and imported it with no data in the tables and it put the entity fields in the correct order. The only difference I can see between the DB that puts fields in alpha-order, and the one that doesn't is the one that puts fields in alpha-order has foreign keys on a few of the tables, and the one that puts the fields in the correct order has no foreign keys on any table. So, it's looking more and more like a fluke. If you like, I will send you the SQL dump that when imported into MySQL causes the alpha-order issue, but as far as I'm concerned this is resolved for me, and I hope I haven't wasted too much of your time. You guys really take customer service to the next level! Just so you know, I recommend Skipper to everyone I know that has a need for it.

Hi, thanks for the all details. Maybe we find a solution to this issue.

Can you please try latest beta uploaded here: https://www.skipper18.com/support/402/downloads-skipper-beta

Thanks

1 Answer

+1 vote
Best answer
by Skipper developer (141k points)