4

I have created one plugin "tuition" and install that in moodle(2.5.2) from moodle/blocks directory. After that I have tried to create some table from new Plugin (tuition). I have created install.xml file in tuition/db/ directory and change the version in version.php file. when I update my tuition plugin, it shows that plugin is updated successfully but it doesn't create any table. I have attached my install.xml file here.

please some one tell me where is the problem to update the plugin

    <?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/label/db" VERSION="20060905" COMMENT="XMLDB file for Moodle mod/label"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
  <TABLES>

<TABLE NAME="block_tuition_comments">
      <FIELDS>
        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="instanceid"/>
        <FIELD NAME="instanceid" TYPE="char" LENGTH="20" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="createdbyid"/>
        <FIELD NAME="createdbyid" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="instanceid" NEXT="dt"/>
        <FIELD NAME="dt" TYPE="datetime" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="createdbyid" NEXT="message"/>
        <FIELD NAME="message" TYPE="char" LENGTH="300" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="dt"/>
      </FIELDS>
      <KEYS>
        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
      </KEYS>
    </TABLE>

  </TABLES>

</XMLDB>

part of install.xml file

Tushar
  • 139
  • 1
  • 3
  • 12

3 Answers3

3

If the plugin is already installed then install.xml is ignored.

You can either manually delete the version so it's like a fresh install - only does this in development though not in production.

Find the correct record and delete it

SELECT * from mdl_config_plugins
WHERE plugin like '%tution%'
AND name = 'version'

Or if your plugin is already on a live site then you will need to create a db/upgrade.php file

http://docs.moodle.org/dev/Upgrade_API#The_files_you_need_for_the_second_release

Have a look at existing code in moodle for examples

One more note, rather than writing the install.xml file yourself, you should use the xmldb editor - this can also generate php code which you can use in your upgrade.php file

http://docs.moodle.org/dev/XMLDB_editor

You will find it in site admin -> development -> xmldb editor

Russell England
  • 9,436
  • 1
  • 27
  • 41
0

If you made changes after plugin installation then changes will not be reflected, You need to uninstall/delete plugin (don't need to remove code from moodle) then run notification on site. you will see plugin to be installed in the page complete that process everything will be updated.

Go through following path in your site to uninstall/delete plugin

Home ► Site administration ► Plugins ► Blocks ► Manage blocks

This path varies according to plugin type.

Here you will get list of blocks, delete option will be there with each block.

sumit
  • 332
  • 2
  • 7
0

If the plugin is already installed then install.xml is ignored. You made any changes after plugin installation then changes will not be reflected. install.xml file update database only at fresh installation of plugin. You have to uninstall/delete your plugin. Before you uninstall plugin you have to copy plugin folder (tuition) at another location.You can uninstall plugin from following path

Home ► Site administration ► Plugins ► Blocks ► Manage blocks

After complete uninstall plugin you move this folder in block folder again. Now you go following path to re-install plugin

Home ► Site administration ► Plugins ► Blocks ► Notifications

After successfully installation you will find your table in your database.