You are viewing the PKP Support Forum | PKP Home Wiki

Using schema-file

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

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

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

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: 17
Joined: Tue Oct 20, 2009 12:48 pm

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: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

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: http://www.carpet-project.net/forum/ -> Erzeugen einer Tabelle für ein OJS-PlugIn and it ends up with a bug report: http://pkp.sfu.ca/bugzilla/show_bug.cgi?id=5943.
Posts: 17
Joined: Tue Oct 20, 2009 12:48 pm

Return to OJS Development

Who is online

Users browsing this forum: Google [Bot] and 3 guests