<?php
use Migrations\AbstractMigration;

class NormalizeUserEmptyAudioInfo extends AbstractMigration
{
    public function up()
    {
        $table = $this->table('users');
        $table->changeColumn('audio_license', 'string', [
            'limit' => 50,
            'null' => false,
            'default' => '',
        ]);
        $table->changeColumn('audio_attribution_url', 'string', [
            'limit' => 255,
            'null' => false,
            'default' => '',
        ]);
        $table->update();
    }
}

Fix NULL/empty string inconsistencies in database
Fix NULL/empty string inconsistencies in database

The fields audio_license and audio_attribution_url are initialized
to NULL, but if you save your audio settings (using the form on
/audio/of/<username>), these fields are saved to empty strings when
left blank. This have created inconsistences between users having
NULL and those having empty strings there, having to use SQL
conditions like "audio_license is not null and audio_license <> ''".

This commit solves the problem by setting the fields as non-nullable.
