Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ctwx's avatar
Level 1

How to upgrade the session table?

I hope I'm doing it right and this is the text input field for my question... (I have to admit, that I'm kinda confused by the design.)

I am working through the upgrade guide to upgrade my applications from Laravel 5.1 to 5.2 (https://laravel.com/docs/master/upgrade#upgrade-5.2.0). There's the section Database Session Driver that states:

If you would like to use the new driver, you should add the user_id (nullable integer), ip_address (nullable string), and user_agent (text) columns to your session database table.

To my knowledge the database is created by the migrations so there should be a hint to this, but looking into the Laravel git repository I can't spot any difference: https://github.com/laravel/laravel/blob/master/database/migrations/2014_1012000000_create_users_table.php (it seems that the markup doesn't like this link... I miss the good old [URL] syntax :S)

How am I supposed to do that? What should I actually do?

0 likes
2 replies
bobbybouwmann's avatar

I guess you need to read a bit better

If you would like to use the new driver, you should add the user_id (nullable integer), ip_address (nullable string), and user_agent (text) columns to your session database table.

It clearly says session database table. Also this is not a default migration, but a command: The command can be found here: https://github.com/laravel/framework/blob/5.2/src/Illuminate/Session/Console/SessionTableCommand.php The migration can be found here: https://github.com/laravel/framework/blob/5.2/src/Illuminate/Session/Console/stubs/database.stub

jwadhams's avatar

If you're migrating from 5.1 up to 5.2, here's a migration that just adds the new fields. It's not that it's hard to write, but it is odd that there's not one pre-tested in the docs.

https://gist.github.com/jwadhams/f666cce6fde538360cef1b3d3dfa89e5

You'd probably want to paste this content into a migration you start with artisan so it applies in the right order.

php artisan make:migration sessions52
2 likes

Please or to participate in this conversation.