Using schema-file

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
The Public Knowledge Project Support Forum is moving to

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.
Posts: 17
Joined: Tue Oct 20, 2009 12:48 pm

Using schema-file

Postby Szdnez » Sat Sep 18, 2010 3:58 am


I wrote my first plugin for OJS and it works quite fine. But still I have some problems with the schema-file. My plugin needs its own table in the database. This table is described in a schema.xml that is located in the root directory of my plugin:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE schema SYSTEM "../../../dbscripts/xml/dtd/xmlschema.dtd">

<schema version="0.2">

   <table name="my_first_plugin_with_table">
        <field name="id" type="I8">
        <field name="article_id" type="I8">
        <field name="infos" type="C2" size="255">
        <index name="my_first_plugin_with_table_article_id">

My plugin extends GenericPlugin and overrides getInstallSchemaFile() like this:

Code: Select all

function getInstallSchemaFile()
    return $this->getPluginPath() . '/' . 'schema.xml';

In the documentation you can read that now the table should be created automatically in the database. But not in my case. Always when I try to access my plugin I get the error message that the table does not exists. If I create the table by hand everything works fine. Do you have any idea what is the problem? Do I have to do something more? Or I am wrong that the table is created automatically in the database?
Thanks for you help!

Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Re: Using schema-file

Postby mcrider » Thu Sep 23, 2010 10:45 am

Hi Szdnez,

The schema file won't be installed automatically unless you use the plugin installation tool (from the manager/plugins page). Otherwise, you can execute

Code: Select all

php /ojs/tools/dbXMLtoSQL.php -schema execute /path/to/your/schema.xml

Where in the documentation did you see that the table would be created automatically? I'll update it if its in error.


Posts: 17
Joined: Tue Oct 20, 2009 12:48 pm

Re: Using schema-file

Postby Szdnez » Sun Sep 26, 2010 1:00 pm

Thanks for your help. I am not a OJS administrator or something like that, I just wrote a plugin, so I do not know much about the install proces of plugins. I read in the documentationb(OJS Documentation -> OJS Userguide -> HTML):
3. Additional Plugin Functionality wrote:Schema Management: By overriding getInstallSchemaFile() and placing the named schema file in the plugin directory, generic plugins can make use of OJS's schema-management features. This function is called on OJS install or upgrade.

Because of that and the call of getInstallSchemaFile() on start up of OJS I thought that the table will be created automatically. But it is a little bit more compiclated. I started another thread on a german forum: -> Erzeugen einer Tabelle für ein OJS-PlugIn and it ends up with a bug report:

Return to “OJS Development”

Who is online

Users browsing this forum: No registered users and 1 guest