General developer forum

How update a plugin database to delete a field from it

Picture of Fabio Cunha
How update a plugin database to delete a field from it

I create a plugin for Moodle and this plugin is in the production server now.

But I see that I create a plugin using one not useful field.

This is my install.xml file

<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/videourl/db" VERSION="20101203" COMMENT="XMLDB file for Moodle mod/videourl"
    <TABLE NAME="videourl" COMMENT="Default comment for videourl, please edit me">
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true"/>
        <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Course videourl activity belongs to"/>
        <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="name field for moodle instances"/>
        <FIELD NAME="vidid" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="video id"/>
        <FIELD NAME="numeroexibicao" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false"/>
        <FIELD NAME="intro" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="General introduction of the videourl activity"/>
        <FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Format of the intro field (MOODLE, HTML, MARKDOWN...)"/>
        <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false"/>
        <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false"/>
        <FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="100" SEQUENCE="false" COMMENT="The maximum grade. Can be negative to indicate the use of a scale."/>
        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
        <INDEX NAME="course" UNIQUE="false" FIELDS="course"/>

The "grade" field is not used by the plugin, I want to know how I can use the plugin to remove this field from the database?

Do I need to update the "db/upgrade.php" file to do that?



Average of ratings: -