1

Topic: Extension update question

Is there any way to update an extension without deleting it and without changing version number

Say, I made some minor change to an extension that uses extra database fields. How do I install it?
If I delete it first, database fields will be deleted, but I want to keep them.

Is there any way to install the changed version without changing version number and without deleting it?

2

Re: Extension update question

PunBB automatically compares extension version installed with version which is in manifest.xml, so just update version number and edit <install>

This is for example pun_pm's <install>
[code=php]
// Setup main table
if (!$forum_db->table_exists('pun_pm_messages'))
{
    $schema = array(
        'FIELDS'            => array(
            'id'                => array(
                'datatype'        => 'SERIAL',
                'allow_null'    => false
            ),
            'sender_id'            => array(
                'datatype'        => 'INT(10) UNSIGNED',
                'allow_null'    => false,
                'default'        => '0'
            ),
            'receiver_id'        => array(
                'datatype'        => 'INT(10) UNSIGNED',
                'allow_null'    => true
            ),
            'lastedited_at'        => array(
                'datatype'        => 'INT(10) UNSIGNED',
                'allow_null'    => false,
                'default'        => '0'
            ),
            'read_at'            => array(
                'datatype'        => 'INT(10) UNSIGNED',
                'allow_null'    => false,
                'default'        => '0'
            ),
            'subject'            => array(
                'datatype'        => 'VARCHAR(255)',
                'allow_null'    => false,
                'default'        => '\'\''
            ),
            'body'                => array(
                'datatype'        => 'TEXT',
                'allow_null'    => false
            ),
            'status'            => array(
                'datatype'        => 'VARCHAR(9)',
                'allow_null'    => false,
                'default'        => '\'draft\'',
            ),
            'deleted_by_sender'    => array(
                'datatype'        => 'TINYINT(1)',
                'allow_null'    => false,
                'default'        => '0'
            ),
            'deleted_by_receiver'=> array(
                'datatype'        => 'TINYINT(1)',
                'allow_null'    => false,
                'default'        => '0'
            )
        ),
        'PRIMARY KEY'    => array('id'),
        'INDEXES'        => array(
            'sender_id_idx'        => array('sender_id'),
            'receiver_id_idx'    => array('receiver_id'),
        )
    );

    $forum_db->create_table('pun_pm_messages', $schema);
}
else if (defined('EXT_CUR_VERSION') && version_compare(EXT_CUR_VERSION, '1.1b2', '<')) {
    $forum_db->add_field('pun_pm_messages', 'lastedited_at_new', 'INT(10) UNSIGNED', false, '0');
    $forum_db->add_field('pun_pm_messages', 'read_at_new', 'INT(10) UNSIGNED', false, '0');

    $forum_db->query('UPDATE '.$forum_db->prefix.'pun_pm_messages SET lastedited_at_new = UNIX_TIMESTAMP(lastedited_at)');
    $forum_db->query('UPDATE '.$forum_db->prefix.'pun_pm_messages SET read_at_new = UNIX_TIMESTAMP(read_at)');

    $forum_db->drop_field('pun_pm_messages', 'lastedited_at');
    $forum_db->drop_field('pun_pm_messages', 'read_at');

    $forum_db->query('ALTER TABLE '.$forum_db->prefix.'pun_pm_messages
        CHANGE lastedited_at_new lastedited_at INT(10) UNSIGNED NOT NULL DEFAULT 0,
        CHANGE read_at_new read_at INT(10) UNSIGNED NOT NULL DEFAULT 0,
        MODIFY status VARCHAR(9) NOT NULL DEFAULT \'draft\'') or error(__FILE__, __LINE__);
}

// Add extension options to the config table
if (!isset($forum_config['o_pun_pm_inbox_size']))
{
    $query = array(
        'INSERT'    => 'conf_name, conf_value',
        'INTO'        => 'config',
        'VALUES'    => '\'o_pun_pm_inbox_size\', \'100\''
    );
    $forum_db->query_build($query) or error(__FILE__, __LINE__);
}

if (!isset($forum_config['o_pun_pm_outbox_size']))
{
    $query = array(
        'INSERT'    => 'conf_name, conf_value',
        'INTO'        => 'config',
        'VALUES'    => '\'o_pun_pm_outbox_size\', \'100\''
    );
    $forum_db->query_build($query) or error(__FILE__, __LINE__);
}

if (!isset($forum_config['o_pun_pm_show_new_count']))
{
    $query = array(
        'INSERT'    => 'conf_name, conf_value',
        'INTO'        => 'config',
        'VALUES'    => '\'o_pun_pm_show_new_count\', \'1\''
    );
    $forum_db->query_build($query) or error(__FILE__, __LINE__);
}

if (!isset($forum_config['o_pun_pm_show_global_link']))
{
    $query = array(
        'INSERT'    => 'conf_name, conf_value',
        'INTO'        => 'config',
        'VALUES'    => '\'o_pun_pm_show_global_link\', \'1\''
    );
    $forum_db->query_build($query) or error(__FILE__, __LINE__);
}

// Field for cache
if (!$forum_db->field_exists('users', 'pun_pm_new_messages'))
    $forum_db->add_field('users', 'pun_pm_new_messages', 'INT(10)', true);

// User options
if (!$forum_db->field_exists('users', 'pun_pm_long_subject'))
    $forum_db->add_field('users', 'pun_pm_long_subject', 'TINYINT(1)', false, 1);
[/code]

Eraversum - scifi browser-based online webgame

3 (edited by 8k84 2010-09-05 21:26)

Re: Extension update question

That's the question. I don't want to change version number since it's not my extension and I want to see via extension manager when a new version arrives.

Re: Extension update question

Is what you've added not something that is of interest to the community and therefor could be built into that official extension as an option?

Doesn't disabling, clearing cache and enabling again work in your case though?

5

Re: Extension update question

KeyDog wrote:

Doesn't disabling, clearing cache and enabling again work in your case though?

Yes, that worked, thanks much.