1050: Table 'mdl_certificate_issues' already exists

1050: Table 'mdl_certificate_issues' already exists

by Joel Brondos -
Number of replies: 11

When I added the certificate module to mods with a capitalized folder, I suspect I made a rather big mess of things.

I tried simply to rename the folder, but as Raymond helpfully noted, there are other areas which may have been affected. Probably, by the looks of my most recent error message:

1050: Table 'mdl_certificate_issues' already exists

Save me from myself....

Average of ratings: -
In reply to Joel Brondos

Re: 1050: Table 'mdl_certificate_issues' already exists

by Joel Brondos -

Here is the full script I get when I click on Notifications:

 

This script generated 8 warnings - Scroll to the first warning

certificate


(mysql): CREATE TABLE mdl_certificate ( id BIGINT(10) unsigned NOT NULL auto_increment, course BIGINT(10) unsigned NOT NULL DEFAULT 0, name VARCHAR(255) NOT NULL DEFAULT '', intro TEXT, emailteachers TINYINT(2) unsigned NOT NULL DEFAULT 0, emailothers TEXT, savecert TINYINT(2) unsigned NOT NULL DEFAULT 0, reportcert TINYINT(2) unsigned NOT NULL DEFAULT 0, delivery SMALLINT(3) unsigned NOT NULL DEFAULT 0, certificatetype VARCHAR(50) NOT NULL DEFAULT '', borderstyle VARCHAR(30) NOT NULL DEFAULT '0', bordercolor VARCHAR(30) NOT NULL DEFAULT '0', printwmark VARCHAR(30) NOT NULL DEFAULT '0', printdate BIGINT(10) unsigned NOT NULL DEFAULT 0, datefmt BIGINT(10) unsigned NOT NULL DEFAULT 0, printnumber BIGINT(10) unsigned NOT NULL DEFAULT 0, printgrade BIGINT(10) unsigned NOT NULL DEFAULT 0, gradefmt BIGINT(10) unsigned NOT NULL DEFAULT 0, printoutcome BIGINT(10) unsigned NOT NULL DEFAULT 0, printhours TEXT, lockgrade BIGINT(10) unsigned NOT NULL DEFAULT 0, requiredgrade SMALLINT(4) unsigned NOT NULL DEFAULT 0, printteacher BIGINT(10) unsigned NOT NULL DEFAULT 0, customtext TEXT, printsignature VARCHAR(30) NOT NULL DEFAULT '0', printseal VARCHAR(30) NOT NULL DEFAULT '0', timemodified BIGINT(10) unsigned NOT NULL DEFAULT 0, CONSTRAINT PRIMARY KEY (id) )


1050: Table 'mdl_certificate' already exists

            ADOConnection._Execute(CREATE TABLE mdl_certificate (
id BIGINT(10) unsigned NOT NULL auto_increment,
course BIGINT(10) unsigned NOT NULL DEFAU..., false)
% line 891, file: adodb.inc.php
      ADOConnection.Execute(CREATE TABLE mdl_certificate (
id BIGINT(10) unsigned NOT NULL auto_increment,
course BIGINT(10) unsigned NOT NULL DEFAU...)
% line 89, file: dmllib.php
    execute_sql(CREATE TABLE mdl_certificate (
id BIGINT(10) unsigned NOT NULL auto_increment,
course BIGINT(10) unsigned NOT NULL DEFAU..., true)
% line 2302, file: dmllib.php
  execute_sql_arr(Array[11]) % line 635, file: ddllib.php
install_from_xmldb_file(/home/content/j/b/r/jbrondos2/html/illa.us/moodle/mod/certificate/db/install.xml) % line 390, file: adminlib.php

(mysql): ALTER TABLE mdl_certificate COMMENT='Defines certificates'


Success

(mysql): CREATE TABLE mdl_certificate_issues ( id BIGINT(10) unsigned NOT NULL auto_increment, certificateid BIGINT(10) unsigned NOT NULL DEFAULT 0, userid BIGINT(10) unsigned NOT NULL DEFAULT 0, timecreated BIGINT(10) unsigned NOT NULL DEFAULT 0, studentname VARCHAR(40) NOT NULL DEFAULT '', code VARCHAR(40) DEFAULT NULL, classname VARCHAR(254) NOT NULL DEFAULT '', certdate BIGINT(10) unsigned DEFAULT 0, reportgrade VARCHAR(10) DEFAULT NULL, mailed TINYINT(1) unsigned NOT NULL DEFAULT 0, CONSTRAINT PRIMARY KEY (id) )


1050: Table 'mdl_certificate_issues' already exists

            ADOConnection._Execute(CREATE TABLE mdl_certificate_issues (
id BIGINT(10) unsigned NOT NULL auto_increment,
certificateid BIGINT(10) unsigned ..., false)
% line 891, file: adodb.inc.php
      ADOConnection.Execute(CREATE TABLE mdl_certificate_issues (
id BIGINT(10) unsigned NOT NULL auto_increment,
certificateid BIGINT(10) unsigned ...)
% line 89, file: dmllib.php
    execute_sql(CREATE TABLE mdl_certificate_issues (
id BIGINT(10) unsigned NOT NULL auto_increment,
certificateid BIGINT(10) unsigned ..., true)
% line 2302, file: dmllib.php
  execute_sql_arr(Array[11]) % line 635, file: ddllib.php
install_from_xmldb_file(/home/content/j/b/r/jbrondos2/html/illa.us/moodle/mod/certificate/db/install.xml) % line 390, file: adminlib.php

(mysql): ALTER TABLE mdl_certificate_issues COMMENT='Info about issued certificates'


Success

(mysql): CREATE TABLE mdl_certificate_linked_modules ( id BIGINT(10) unsigned NOT NULL auto_increment, certificate_id BIGINT(10) unsigned NOT NULL DEFAULT 0, linkid BIGINT(10) NOT NULL DEFAULT 0, linkgrade BIGINT(10) NOT NULL DEFAULT 0, timemodified BIGINT(10) unsigned NOT NULL DEFAULT 0, CONSTRAINT PRIMARY KEY (id) )


1050: Table 'mdl_certificate_linked_modules' already exists

            ADOConnection._Execute(CREATE TABLE mdl_certificate_linked_modules (
id BIGINT(10) unsigned NOT NULL auto_increment,
certificate_id BIGINT(10) ..., false)
% line 891, file: adodb.inc.php
      ADOConnection.Execute(CREATE TABLE mdl_certificate_linked_modules (
id BIGINT(10) unsigned NOT NULL auto_increment,
certificate_id BIGINT(10) ...)
% line 89, file: dmllib.php
    execute_sql(CREATE TABLE mdl_certificate_linked_modules (
id BIGINT(10) unsigned NOT NULL auto_increment,
certificate_id BIGINT(10) ..., true)
% line 2302, file: dmllib.php
  execute_sql_arr(Array[11]) % line 635, file: ddllib.php
install_from_xmldb_file(/home/content/j/b/r/jbrondos2/html/illa.us/moodle/mod/certificate/db/install.xml) % line 390, file: adminlib.php

(mysql): ALTER TABLE mdl_certificate_linked_modules COMMENT='Defines certificate dependencies'


Success

(mysql): INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'view', 'certificate', 'name')


1062: Duplicate entry 'certificate-view' for key 2

            ADOConnection._Execute(INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'view', 'certificate', 'name'), false) % line  891, file: adodb.inc.php
      ADOConnection.Execute(INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'view', 'certificate', 'name')) % line 89, file: dmllib.php
    execute_sql(INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'view', 'certificate', 'name'), true) % line 2302, file: dmllib.php
  execute_sql_arr(Array[11]) % line 635, file: ddllib.php
install_from_xmldb_file(/home/content/j/b/r/jbrondos2/html/illa.us/moodle/mod/certificate/db/install.xml) % line 390, file: adminlib.php

(mysql): INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'add', 'certificate', 'name')


1062: Duplicate entry 'certificate-add' for key 2

            ADOConnection._Execute(INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'add', 'certificate', 'name'), false) % line  891, file: adodb.inc.php
      ADOConnection.Execute(INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'add', 'certificate', 'name')) % line 89, file: dmllib.php
    execute_sql(INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'add', 'certificate', 'name'), true) % line 2302, file: dmllib.php
  execute_sql_arr(Array[11]) % line 635, file: ddllib.php
install_from_xmldb_file(/home/content/j/b/r/jbrondos2/html/illa.us/moodle/mod/certificate/db/install.xml) % line 390, file: adminlib.php

(mysql): INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'update', 'certificate', 'name')


1062: Duplicate entry 'certificate-update' for key 2

            ADOConnection._Execute(INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'update', 'certificate', 'name'), false) % line  891, file: adodb.inc.php
      ADOConnection.Execute(INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'update', 'certificate', 'name')) % line 89, file: dmllib.php
    execute_sql(INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'update', 'certificate', 'name'), true) % line 2302, file: dmllib.php
  execute_sql_arr(Array[11]) % line 635, file: ddllib.php
install_from_xmldb_file(/home/content/j/b/r/jbrondos2/html/illa.us/moodle/mod/certificate/db/install.xml) % line 390, file: adminlib.php

(mysql): INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'report', 'certificate', 'name')


1062: Duplicate entry 'certificate-report' for key 2

            ADOConnection._Execute(INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'report', 'certificate', 'name'), false) % line  891, file: adodb.inc.php
      ADOConnection.Execute(INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'report', 'certificate', 'name')) % line 89, file: dmllib.php
    execute_sql(INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'report', 'certificate', 'name'), true) % line 2302, file: dmllib.php
  execute_sql_arr(Array[11]) % line 635, file: ddllib.php
install_from_xmldb_file(/home/content/j/b/r/jbrondos2/html/illa.us/moodle/mod/certificate/db/install.xml) % line 390, file: adminlib.php

(mysql): INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'received', 'certificate', 'name')


1062: Duplicate entry 'certificate-received' for key 2

            ADOConnection._Execute(INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'received', 'certificate', 'name'), false) % line  891, file: adodb.inc.php
      ADOConnection.Execute(INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'received', 'certificate', 'name')) % line 89, file: dmllib.php
    execute_sql(INSERT INTO mdl_log_display(module, action, mtable, field) VALUES ('certificate', 'received', 'certificate', 'name'), true) % line 2302, file: dmllib.php
  execute_sql_arr(Array[11]) % line 635, file: ddllib.php
install_from_xmldb_file(/home/content/j/b/r/jbrondos2/html/illa.us/moodle/mod/certificate/db/install.xml) % line 390, file: adminlib.php
In reply to Joel Brondos

Re: 1050: Table 'mdl_certificate_issues' already exists

by Raymond Fürst -

I think you need to clean up this mess before you can go any further (I hope it is not a productive site you are working on).

If the hint from Chris Collman in the other forum thread does not work, you should restore your moodle system to a state before you started installing the certificate module. If you are unable to do this (or doing so would cause too much data to be lost) you should do the following:

  1. Delete any certificate folders from your %moodledir%/mod-folder named whatsoever
  2. Use phpmyadmin or any other database administration tool to delete/drop the certificate-related tables out of the moodle database:
    mdl_certificate
    mdl_certificate_issues
    mdl_certificate_linked_modules
    There should be no tables beginning with mdl-certificate be left on your database.
  3. Run the notifications page. You should receive no errors or warnings.
  4. Install the certificate module into a folder %moodledir%/mod/certificate. The folder name is "certificate" without capital-C and without plural-s.
  5. If your site language is not english, copy the language file from %moodledir%/mod/certificate/lang/en_utf8/certificate.php into a new folder %moodledir%/mod/certificate/lang/%yourlangcode% and edit it to translate.
  6. Run the notifications page again. You should receive no errors or warnings.
  7. After that, you can enter any course and find an entry "certificate" in the add-activity-dropdown-box
Average of ratings: Useful (2)
In reply to Raymond Fürst

Re: 1050: Table 'mdl_certificate_issues' already exists

by Joel Brondos -

@ Raymond

If the following php files are listed in the error messages, are these the ones I would (1) backup, (2) access via phpmyadmin to delete any mdl_certificate* tables? Or is there some other Moodle database file in particular where I will find the mdl_certificate* tables? (I'm still learning about how Moodle saves its tables/questions/etc.)

  • line 103 of lib/dmllib.php: call to debugging()
  • line 2302 of lib/dmllib.php: call to execute_sql()
  • line 635 of lib/ddllib.php: call to execute_sql_arr()
  • line 390 of lib/adminlib.php: call to install_from_xmldb_file()
  • line 433 of admin/index.php: call to upgrade_activity_modules()

Do I locate these files in my Moodle installation, download them, edit them, and then re-upload them?

Does it make any difference if the site is running mysql or postgres?

 

Thanks,

Joel

In reply to Joel Brondos

Re: 1050: Table 'mdl_certificate_issues' already exists

by Raymond Fürst -

In a productive environment you should perform a backup of your entire moodle site on a regular basis. Usually the administrator configures some automatic tasks (called cron-jobs in the unix world) so that the system shuts down the web server, freezes the database, copies all files (including the ones that form the database) into a backup folder and finally restarts all services back online. On my site this is done once every night. Should some terrible things happen to the system during the day, restoring the backup puts the system in the state of the previous morning.

Moodle is a complex system. Some parts come from a database, some from the various folders and files throughout you moodle-dir. Usually, modifications to the system (such as including a new module) work pretty seamlessly. Some files in the folder of a new module tell moodle how to make the appropriate changes to the database. Those steps are automatically undone if the module is deleted from the modules page in the administrators block, just as Chris pointed out in the other forum post.

In your case, the module files were in a folder carrying a different name than that is used in the module code inside these files. Obviously the database-part of the installation worked, but other parts not. You need to undo this installation properly.

Go to Admin-block -> Plugins -> Activities -> Overview. Is there still a certificate entry in this table? Then you should be able to uninstall it by clicking on "Delete" in the corresponding row. After that, remove the misspelled certificate-folder from your moodle/mod/-folder or rename it to "certificate" as it should be. If you have installed the optional certificate blocks (report_my_certificates and verify_certificates), you should delete them as well. You will find those in Admin->Plugins->Blocks->Overview

You need a database tool like phpmyadmin to examine the database structure of your moodle. The database consists of many tables that administer your moodle data, and many modules add their own tables to the database. All Moodle tables have a name that usually begins with "mdl_". This might be different on your system. The database might be used for other applications other than moodle, and it is possible to run two moodles using one database. In that case one of the moodles will be configured to have table names with a different prefix.

The certificate module uses tables that begin with "mdl_certificate_". Check if tables beginning with that name still exist after deleting the module from the admin block. If they exist, you can drop the tables using phpmyadmin. Ask your server administrator for help, he might have to add phpmyadmin to your system, or he knows how to clean up the tables.

If no traces of certificate can be found in the database, then you can attempt to reinstall the module. Doublecheck the /mod/certificate-folder name first. Install only the certificate-module, the additional blocks should be added later if the installation of certificate was successful.

Average of ratings: Useful (1)
In reply to Raymond Fürst

Re: 1050: Table 'mdl_certificate_issues' already exists

by Joel Brondos -

@ Raymond,

You are especially gracious to take so much time to help me learn Moodle and deal with my problem. Thank you.

Two quick isses which I hope (for your time) have easy/brief answers smile:

1) What do you mean by "the database" when you write "If no traces of certificate can be found in the database" ? Is that a particular php file found under /moodle? Or is it better to ask, "Where do I find the Moodle tables"?

2) Does it matter for installation of modules like "certificate" if my Moodle installation is running mysql or postgres? Which of those two is "better"?

Joel

In reply to Joel Brondos

Re: 1050: Table 'mdl_certificate_issues' already exists

by Raymond Fürst -

Well, I'll try to be concise:

  1. As stated in my prevous post, a moodle system consists of several parts. Moodle itself is written in php, but it needs some extra parts to be able to run:
    - a server with a running operating system
    - a webserver like apache. This is responsible for making the moodle system visible for student clients.
    - a php interpreter. This is needed to enable the webserver to run the moodle code, that is written in php.
    - a database. This is used by moodle to store most of the learning data, and it must fit to moodle and the webserver. Usually it is mysql, but it can be postgres or any other system that works with moodle.
    A server with all these components is called a LAMP-Server (Linux-Apache-MySQL-PHP). LAMP-Servers are quite common for many applications that provide services to the internet (like moodle).
    Note that the database is a part of the server infrastructure, not of moodle itself. Moodle just requires a database to be installed on the server and prepared to be used with moodle.
  2. It is difficult to say which database is better. Sometimes certain constrains limit you in this choice, like knowledge about the database, the database being part of the server package or company policy. Both database systems are suitable for moodle, I think mysql is more common.
    Database access is handled via special functions, that are adjusted to the database system. Those functions send database commands to the database (such as SELECT, CREATE TABLE etc.) and retreive the results to process further in moodle or display to the screen. The functions are defined in a special database library, that is part of moodle.
    Any module that uses a database, uses the same functions. So technically it makes no difference what database system moodle is connected to, as long as it can handle all those functions. The module tells the database just what tables it wants to be created (during installation) and what data it wants to store and to read.

One final note about databases:

A database is more a service/daemon, less a program or application that is visible to the user. This turns databases into magical components that are difficult to grasp.

Usually moodle handles all database access automatically, and you do not need to poke around in the database itself. All the things you need to see from the database is visible through normal moodle pages (such as the profile page that displays all data that moodle stores about your profile in the database).

If you need database administrator's access to the database, you might need special tools to do that. For php, phpmyadmin  is such a tool. This gives you access to the guts of the database (at a very technical level). As you can do some very nasty things to the database, you should ask a database guru who is familiar with your system for assistance.

The final option (in case everything is totally messed up beyond repair) is blowing up your entire system and reinstall everything from scratch to have a clean system.

Average of ratings: Useful (1)
In reply to Raymond Fürst

Re: 1050: Table 'mdl_certificate_issues' already exists

by Joel Brondos -

Raymond, this post is VERY helpful in providing the BIG picture.

The LITTLE question I have is this: In what file/database/table will I find "mdl_certificate" so that I can delete it?

I have a php editor, but I don't know which file to open in order to deal with "mdl_certificate" and similar tables.

In other words, in what files are the tables stored for the Certificate module? (Is it foolish to attempt to edit "tables"?)

I suppose as a last resort I could back up my courses, blow up Moodle, and start over -- perhaps with version 2.0.

In reply to Joel Brondos

Re: 1050: Table 'mdl_certificate_issues' already exists

by Raymond Fürst -

You cannot use a text editor to make changes to the database.

You need to install a database administration tool like phpmyadmin. It will show you what databases are installed in your system, gives you a list of tables and lets you make changes to the tables or the entries within.

Average of ratings: Useful (1)
In reply to Raymond Fürst

Re: 1050: Table 'mdl_certificate_issues' already exists

by Joel Brondos -

Okay. I understand now (and apologize) that I was asking the wrong kind of question.

Perhaps others can learn from my mistake!

I was thinking that Moodle data and tables were installed in FILES and that I would download and edit the files before uploading them again.

But phpmyadmin doesn't work that way . . . and the information isn't in "files" the way I've been thinking.

It's more like being logged on to the website itself and editing through a resource like phpmyadmin, perhaps comparable to being logged in with an FTP "program" (though that might not be an adequate comparison).

I hope it wasn't too painful to put up with my ignorance! Thanks, Raymond, for your patience and sharing your insights.

In reply to Joel Brondos

Re: 1050: Table 'mdl_certificate_issues' already exists

by Raymond Fürst -

Right, now you got it.

The database is the only part of moodle that you cannot change by manipulating files inside the moodle folder.

The FTP-program is not a good example, because it's purpose is to shove files around. A better anology might be the regedit-program in Windows. Installing and using programs modifies the windows registry. You cannot poke around in the underlying files (user.dat etc.), you need regedit to make the registry data visible and accessible.

Average of ratings: Useful (1)
In reply to Raymond Fürst

Re: 1050: Table 'mdl_certificate_issues' already exists

by peshala amarasingha -
If i insert values into a moodle table with phpmyadmin , will it update everywhere else aswell? I am totally new to moodle , if someone can help , i'm great full!