• chevron_right

      From Modl to Eloquent, or how to change a social network database engine

      Timothée Jaussoin · pubsub.movim.eu / Movim · Tuesday, 17 April, 2018 - 08:53 edit · 2 minutes

    After 50 hours of work, more than 5000 line added and 10000 deleted, and 250 files changed it's finally done. This is the biggest refactoring done in the history of the project.

    Movim is a social network and instant messaging web client for the XMPP network. It grab data from XMPP and store them temporary in a SQL database to present it in a light and simple UI to the users.

    A Community on Movim, all the posts here are on XMPP and cached in the Movim database

    The database library is therefore a really important piece of the architecture.

    The idea was to replace the historical database layer (Modl) with Eloquent the reference database library of the Laravel project. This will bring many new interesting features to the project:

    • Have a more organized database with proper relations between the tables, have indexes and foreign keys (some of those features were missing in Modl)
    • Be able to do advanced queries to present more interesting content to the user
    • Simplify the code of the project (this is also why several thousands lines were removed from the code base)

    Most of the existing features were ported to the Eloquent, some others are temporary disabled or simplified. Those, like the suggestions of Posts and Contacts, will be improved in the upcoming months.

    You can also expect many small bugs here and there. The plan is to take a couple of weeks (months?) more to stabilize the code and do a proper 0.14 release.

    For those that want to try out the current release, the Installation Tutorial on our wiki has been updated to reflect the changes introduced in this release. Here is a small sum-up.

    Migrate from 0.13.* to 0.14+

    Be sure to do a backup of your database before. It only takes a few seconds and it will allow you to do it again if you have any trouble during the migration. For PostgreSQL you can do.

    pg_dump -d movim_db > movim_backup.sql
    

    Then you can turn off the Movim service, if you are using systemd you can do.

    service movim stop
    

    Go to the Movim path and pull the new code, then update the Composer dependencies.

    git pull
    composer install
    

    You don't have to change anything in the configuration, the daemon will also refuse to start if some of the following steps are not finished properly.

    You can then migrate the database to create the new structure.

    php vendor/bin/phinx migrate
    

    Movim is also coming with a migration script. It will:

    • Move the existing users and their configurations to the new tables
    • Migrate the default Movim configuration
    • Migrate the database cache
    • Migrate the chatroom invitations script
    • Destroy all the old Modl table

    You can call this script with the following command

    php vendor/bin/phinx seed:run -s FromModlToEloquent
    

    Once everything is done you can then restart the daemon :)

    service movim start
    

    Like always you can help us by covering our monthly costs on the Patreon page or by doing a one time donation on Paypal.

    You can also help us by writing blog posts, tutorials or talk about the project on the other platforms (Reddit, Twitter, HackerNews…) :) If you have remarks or questions, do not hesitate to join us on the official chatroom, movim@conference.movim.eu.

    That's all folks!

    • wifi_tethering open_in_new

      This post is public

      nl.movim.eu

    • Pictures 1 image

    • visibility
    • favorite

      10 Like

      odomar, valeg, Adrien Dorsaz, bigou, Baudouin Feildel, Roelof Pieter, valk974, bigou, debacle, Bigou, le VRAI!