-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Please support MySQL 8+ (and upgrade to Laravel 5.7) #6701
Comments
Per the v5 update, the upcoming version of Snipe-IT will be using Laravel 5.7 (and all dependencies are pulled forward accordingly.) You probably could have saved yourself a lot of time by reading the pinned issue, or opening up an issue asking about laravel 5.7 before spending all the time manually dragging it forward. V5 has been in development for 6 months. |
Hmm. Well, on the one hand that's great! I'm happy development is ongoing and this great project isn't going stale. On the other hand I do feel quite silly now, and a bit resentful about your reply. Hardly makes me want to contribute to this project...not that you need any help obviously. On the more pragmatic side, I would like to humbly offer some suggestions:
End of rant :-) Good luck with your project! I look forward to testing it all out again once the v5 is released. |
MySQL 8 support is a definite requirement! |
Your requirements documentation states "MySQL or MariaDB" - so I went ahead and tried to install on my server with MySQL 8.0.14
I'd like to
Environment:
I went ahead and spent a few hours getting SnipeIT to work in the above environment, and it IS working...mostly. But of course you will have to do way more than I to do a proper upgrade. Nonetheless, I wanted to share my experiences, it may help you in your own migration path.
DISCLAIMER: I don't recommend anyone to actually follow what I describe below, I would just like to share it in case it might be useful for the SnipeIT team when doing the actual upgrade. They will have to follow these steps and more for sure! Also, I'm a YII guy and this is my first time diving into Laravel so I'm sure I'm making some mistakes.
So I installed snipe-it and got going with /setup/migrate until I hit my first issue:
Issue no. 1: unescaped reserved word table name "groups" in migration script
This is described originally in issue #6023 and #6181
Caused by
This upgrade script:
/database/migrations/2014_11_04_231416_update_group_field_for_reporting.php
Includes two lines like:
However "groups" has become a reserved word in MySQL 8+
So it needs to be properly escaped.
Solution
Update the script to use Laravel's query builder instead of running a raw SQL query. The query builder will properly escape your table names for you.
So replace the above with:
Issue no. 2: Laravel 5.5 does not support changed MySQL schema
So now you will hit this issue:
Caused by
Starting MySQL 8, information_schema.tables has field names in uppercase, whereas Laravel 5.4 expects this field to be lowercase.
This has been reported here and the solution was implemented in Laravel 5.5.
So basically you could create a temporary hack to resolve this by automatically patching the relevant file in /vendor or you could just do the right thing and migrate to the latest stable Laravel version.
Solution
Update to Laravel 5.5+
Issues with upgrading to Laravel 5.7
So of course you can't just update one component in composer.json. To get snipe-it working I had to update the following lines:
Additionally, I had to remove this part from composer.json:
Undefined class constant 'HEADER_CLIENT_IP'
So first you will get the dreaded "Class does not exist" error! Follow the instructions in the link to get to the original exception and you will see that the actual issue is this:
You will get this even if you try a sudo php artisan config:clear.
Similar issues have been dealt with here and here, of course the proper solution when doing an upgrade would be to follow the official upgrade guide unfortunately they do not go into much detail.
The actual problem is caused by a change in how trusted proxies need to be configured. More info on that in the official docs.
Solution
Migrate your trusted proxy configuration as follows:
Delete
/config/trustedproxy.php
Upload the following to
/app/Http/Middleware/TrustProxies.php
:Call to undefined method Monolog\Logger::getMonolog()
You will hit this is you even try to do a sudo php artisan config:clear.
The issue is simple, getMonolog() needs to be replaced with Log::getLogger() as described here. Or read more about logging in the official docs.
The error is coming from the following file, however it may be worth looging over all of your files:
/app/Providers/AppServiceProvider.php
Change:
To:
laravel Undefined index: App\Models\CustomField
Reload the page and migration continues, until it hits the next error:
This is because Laravel 5.7 initializeTraits breaks models that override the boot method
Solution
Call
parent::boot();
anywhere where you extend Eloquent\Model! The specific error can be overcome by fixing/app/Models/CustomField.php
:Old:
New:
App\Models\CustomField::rules must return a relationship instance.
So now if you retry the db migration, you get stuck with this error:
I forget how I got to the solution :-( in any case this seems to work: update
/app/Models/CustomField.php
: as follows: just add the following anywhere: (too many colons, I know):!! I am not too comfortable with this as there already is a
public function validationRules()
further down in that class but it does get us moving.Table 'tipton_assets.oauth_clients' doesn't exist
Luckily this can be overcome by running
sudo php artisan migrate
as [described here] (#4439) (this is required because we updated laravel/passport in composer.json)Undefined variable: color
We are getting close!
This now has to do with migrating to Laravel 5.7: L5.7 Undefined variable for Mail Vendor
Of course the right thing would be to properly follow the official 5.6 to 5.7 migration guide!
The solution is to replace "or" with "??" in all of the files under /resources/views/vendor/mail/html. The error is specifically coming from
button.blade.php
which can be fixed as follows:Old:
New:
laravel An Error has occured! Unauthenticated.
So now the platform loads, and you are able to insert records, but you can't see them! If you get your browser debugger up and check the network traffic when you try to reload any table, you'll see this error.
Long story short, you need to make sure to upgrade the laravel passport version in composer.php:
TODO:
Well I can now use most of the platform but things are still not perfect...for example for some off reason whenever I browse to "deployed assets", the SQL being executed is this:
I've run out of time so I can't figure out why it's adding "company_id" and "order_number" as search parameters so if anyone has any ideas please share!
The text was updated successfully, but these errors were encountered: