• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Mod installation: Altering Database Tables

In vBulletin I was used to alter database tables like this:

            'name'       => 'fieldname',
            'type'       => 'int',
            'length'       => '10',
            'null'       => false,
            'default'    => '0'
        ), false);
But this commands are not working anymore. How do they have to look like?
This is kind of dirty, and there is probably a better way to do this, but this should work.

// to add a column to a table
$db->query('ALTER TABLE the_table ADD COLUMN randomCol INT(10) NOT NULL DEFAULT 0;');

// to remove a column from a table
$db->query('ALTER TABLE the_table DROP COLUMN randomCol;');


Well-known member
For your on addon, you need an instance of the $db object first:

$db = XenForo_Application::get('db');

$db->query('ALTER TABLE .....