Course Restore DB Error - mdl_workshop_submissions Table Doesn't Exist

Re: Course Restore DB Error - mdl_workshop_submissions Table Doesn't Exist

by Ken Task -
Number of replies: 6
Picture of Particularly helpful Moodlers

Waited to see how many (if any) responses to this  'issue' ... none ... so I'll offer 2 cents ... in a 'nutshell', if it hurts, don't do it! smile

Suggest using a 'true to moodle life' senario in testing backups and restores.  I imagine that Testers of any Moodle release do test backups and restores but not many (venturing a guess) if any would do the steps you've described here.  While in theory, the backup/restores routines/code should allow any/every combination of settings, can see that conflicting decisions could cause a state of total confusion for Moodle thus rendering mis-leading debugs.

Table missing ... got ssh/shell access?  Use mysql client on server and issue the following from the mysql> prompt using DB for Moodle:

mysql> use moodle36;

mysql> show tables like '%workshop%';

You should see:

+----------------------------------+
| Tables_in_moodle36 (%workshop%)  |
+----------------------------------+
| mdl_workshop                     |
| mdl_workshop_aggregations        |
| mdl_workshop_assessments         |
| mdl_workshop_grades              |
| mdl_workshop_submissions         |
| mdl_workshopallocation_scheduled |
| mdl_workshopeval_best_settings   |
| mdl_workshopform_accumulative    |
| mdl_workshopform_comments        |
| mdl_workshopform_numerrors       |
| mdl_workshopform_numerrors_map   |
| mdl_workshopform_rubric          |
| mdl_workshopform_rubric_config   |
| mdl_workshopform_rubric_levels   |
+----------------------------------+
14 rows in set (0.01 sec)

Check the specific table mentioned:

mysql> explain mdl_workshop_submissions;

should see:

+----------------------+---------------+------+-----+---------+----------------+
| Field                | Type          | Null | Key | Default | Extra          |
+----------------------+---------------+------+-----+---------+----------------+
| id                   | bigint(10)    | NO   | PRI | NULL    | auto_increment |
| workshopid           | bigint(10)    | NO   | MUL | NULL    |                |
| example              | tinyint(2)    | YES  |     | 0       |                |
| authorid             | bigint(10)    | NO   | MUL | NULL    |                |
| timecreated          | bigint(10)    | NO   |     | NULL    |                |
| timemodified         | bigint(10)    | NO   |     | NULL    |                |
| title                | varchar(255)  | NO   |     |         |                |
| content              | longtext      | YES  |     | NULL    |                |
| contentformat        | smallint(3)   | NO   |     | 0       |                |
| contenttrust         | smallint(3)   | NO   |     | 0       |                |
| attachment           | tinyint(2)    | YES  |     | 0       |                |
| grade                | decimal(10,5) | YES  |     | NULL    |                |
| gradeover            | decimal(10,5) | YES  |     | NULL    |                |
| gradeoverby          | bigint(10)    | YES  | MUL | NULL    |                |
| feedbackauthor       | longtext      | YES  |     | NULL    |                |
| feedbackauthorformat | smallint(3)   | YES  |     | 0       |                |
| timegraded           | bigint(10)    | YES  |     | NULL    |                |
| published            | tinyint(2)    | YES  |     | 0       |                |
| late                 | tinyint(2)    | NO   |     | 0       |                |
+----------------------+---------------+------+-----+---------+----------------+
19 rows in set (0.00 sec)

'SoS', Ken


In reply to Ken Task

Re: Course Restore DB Error - mdl_workshop_submissions Table Doesn't Exist

by Jim Arlien -
Thanks, Ken, for your reply. And my apologies for checking out for so long, only returning now. My version of Moodle is now 3.6.6+ (Build 20191008)

I backed up again, but only checked two boxes: activity and resources...and...question bank.

I "Restored into this course", selecting "Delete the contents of this course and then restore." Again I got the error. I also received a litttle message that said the restore was 98.19% complete, and the course seems to be indeed restored and good...at least for my simple scenario with no enrolled users, grade history, groups. or logs.

I issued the mysql commands you gave me and received the following:

MariaDB [mood36]> show tables like '%workshop%';
+---------------------------------------+
| Tables_in_mood36 (%workshop%) |
+---------------------------------------+
| mdl_workshop |
| mdl_workshopallocation_scheduled |
| mdl_workshopeval_best_settings |
| mdl_workshopform_accumulative |
| mdl_workshopform_comments |
| mdl_workshopform_numerrors |
| mdl_workshopform_numerrors_map |
| mdl_workshopform_rubric |
| mdl_workshopform_rubric_config |
+---------------------------------------+
9 rows in set (1.12 sec)

I'm missing five tables compared to your example.


MariaDB [mood36]> explain mdl_workshop_submissions;

ERROR 1146 (42S02): Table 'mood36.mdl_workshop_submissions' doesn't exist

I checked the database and all five of those tables do not exist.

What would be the "best" way to add those tables back without a fresh install or reset?
In reply to Jim Arlien

Re: Course Restore DB Error - mdl_workshop_submissions Table Doesn't Exist

by Ken Task -
Picture of Particularly helpful Moodlers

Qualification for this response ... none ... have never had to do this!!!!

Suggest taking an sql dump of DB for your moodle first before attempting.

Got something to browse files/folders in code?

in a mod/workshop folder/directory of 3.6.highest code, the following files/folders are present:

aggregate.php
allocation
allocation.php
amd
assessment.php
backup
classes
db
editform.php
editformpreview.php
eval
exassessment.php
excompare.php
exsubmission.php
feedbackauthor_form.php
feedbackreviewer_form.php
fileinfolib.php
form
index.php
lang
lib.php
locallib.php
mod_form.php
pix
renderer.php
settings.php
styles.css
submission.php
submission_form.php
switchphase.php
tests
toolbox.php
upgrade.txt
version.php
view.php

Your site?

Rebuild tables that don't exist?????

Login into site as admin
Site Admin
Development
XMLDB Editor

Find mod/workshop/ tables in list
(tables you have missing).

Click Load
Then Edit
Click View SQL code
Next screen should show a view of structure SQL
consisting of create table statements
which one could supposedly copy and paste to a mysql> prompt while using the db for the moodle.

Here are the mod/workshop/x I see in a 3.6.highest sandbox I have:

mod/workshop/allocation/manual/db
mod/workshop/allocation/random/db
mod/workshop/allocation/scheduled/db
mod/workshop/db
mod/workshop/eval/best/db
mod/workshop/form/accumulative/db
mod/workshop/form/comments/db
mod/workshop/form/numerrors/db
mod/workshop/form/rubric/db

If anyone has a better ideas .... PLEASE jump in!

'SoS', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Course Restore DB Error - mdl_workshop_submissions Table Doesn't Exist

by Jim Arlien -
Thanks, Ken!

After verifying that my files/folders matched, you led me to the right place and I was successful with a full restore without error after creating the five tables:
mdl_workshop_aggregations
mdl_workshop_assessments
mdl_workshop_grades
mdl_workshop_submissions
mdl_workshopform_rubric_levels

The first four above were actually under "mdl_workshop" when clicking "Edit".
The last one was under "mdl_rubric".

For each I was able to view the SQL code, copy and paste into either the CLI or PHPmyAdmin sql command window.

I verfied:
MariaDB [mood36]> show tables like '%workshop%';
+-----------------------------------------+
| Tables_in_mood36 (%workshop%) |
+-----------------------------------------+
| mdl_workshop |
| mdl_workshop_aggregations |
| mdl_workshop_assessments |
| mdl_workshop_grades |
| mdl_workshop_submissions |
| mdl_workshopallocation_scheduled |
| mdl_workshopeval_best_settings |
| mdl_workshopform_accumulative |
| mdl_workshopform_comments |
| mdl_workshopform_numerrors |
| mdl_workshopform_numerrors_map |
| mdl_workshopform_rubric |
| mdl_workshopform_rubric_config |
| mdl_workshopform_rubric_levels |
+-----------------------------------------+
14 rows in set (0.00 sec)

MariaDB [mood36]> explain mdl_workshop_submissions;
+----------------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+---------------+------+-----+---------+----------------+
| id | bigint(10) | NO | PRI | NULL | auto_increment |
| workshopid | bigint(10) | NO | MUL | NULL | |
| example | tinyint(2) | YES | | 0 | |
| authorid | bigint(10) | NO | MUL | NULL | |
| timecreated | bigint(10) | NO | | NULL | |
| timemodified | bigint(10) | NO | | NULL | |
| title | varchar(255) | NO | | | |
| content | longtext | YES | | NULL | |
| contentformat | smallint(3) | NO | | 0 | |
| contenttrust | smallint(3) | NO | | 0 | |
| attachment | tinyint(2) | YES | | 0 | |
| grade | decimal(10,5) | YES | | NULL | |
| gradeover | decimal(10,5) | YES | | NULL | |
| gradeoverby | bigint(10) | YES | MUL | NULL | |
| feedbackauthor | longtext | YES | | NULL | |
| feedbackauthorformat | smallint(3) | YES | | 0 | |
| timegraded | bigint(10) | YES | | NULL | |
| published | tinyint(2) | YES | | 0 | |
| late | tinyint(2) | NO | | 0 | |
+----------------------+---------------+------+-----+---------+----------------+
19 rows in set (0.01 sec)

I keep asking myself, "how did we get here anyway?" My original installation was Moodle 2.7.2. I upgraded and patched this same installation again and again right up to current (3.6.6). Somewhere along the way (probably 3.0 or 3.1) the tables were dropped.

I may drop back in here if there are other issues with more complex backups and restores, but for now we're good.

Thanks again, and be sure to take the day off!

-Jim
Average of ratings: Useful (2)
In reply to Jim Arlien

Re: Course Restore DB Error - mdl_workshop_submissions Table Doesn't Exist

by Ken Task -
Picture of Particularly helpful Moodlers

Good to hear!  Wasn't sure cause like I said ... never had to do anything like that.  

Your guess on why those tables missing as good as anyone's ... but might be related ...

when you upgrade do you use git?  Do you 'hyperjump' ... skip versions in upgrading?

And since I did 'lead you' ... how about a 'Useful'? ;)

Other wise, my only reward is to take the day off? :|

'SoS', Ken

Average of ratings: Useful (1)
In reply to Ken Task

Re: Course Restore DB Error - mdl_workshop_submissions Table Doesn't Exist

by Jim Arlien -
Ha! Thanks for leading me to such a "useful" community tool (pretty inexperienced in the forum and gobbling up the wisdom!)

I don't use git and followed the Moodle method of upacking the latest tar, copying in the old config and running the upgrade within Moodle, leaving old data folder untouched...alway in maintenance mode. And no, never jumped versions. At one point -- and I can't recall the version -- I changed the collation of the database to skirt the Antelope-Barracuda error and continue on with only the warning.

Don't know if you enjoy Earl Grey tea from time to time, but cheers in the SoS!

-Jim
In reply to Jim Arlien

Re: Course Restore DB Error - mdl_workshop_submissions Table Doesn't Exist

by Ken Task -
Picture of Particularly helpful Moodlers

Thanks!

Guess we'll never know how those tables went missing.   But as long as that XML editor has them and they can be recovered (without any data), then 'good enough'!  Beats the alt of starting over! ;)

'SoS', Ken