streamingltd / MEDIAL-Moodle-Activity

The MEDIAL activity plugin for Moodle
GNU General Public License v3.0
3 stars 8 forks source link

Restoring a course with a Medial activity on a Postgres based fresh (meaning empty) Moodle installation crashes #13

Open danowar2k opened 10 months ago

danowar2k commented 10 months ago

https://github.com/streamingltd/MEDIAL-Moodle-Activity/blob/master/lib.php#L64-L119

This function uses Postgres incompatible SQL when it wants to change the auto increment of table helixmedia_pre: https://github.com/streamingltd/MEDIAL-Moodle-Activity/blob/bf39e630379d1a9504219753f988b49498454f20/lib.php#L111C11-L111C11

There is no ALTER TABLE AUTO INCREMENT in Postgres. See also https://stackoverflow.com/questions/5342440/reset-auto-increment-counter-in-postgres

Please don't use DBMS specific SQL code in the plugin.

tim1mw commented 10 months ago

That code dates from 2014 and was put in to deal with a problem reported by a customer using MySQL. Since you're on Postgres, which never had the reported problem, I think the immediate solution here is to only run that code block for MySQL and MariaDB DBMS's .

I've put in a change to fix this on the devfixes branch in commit https://github.com/streamingltd/MEDIAL-Moodle-Activity/commit/29bdb614b515efb31acd6fe968a284331815d6bd . I'll roll that into the next full plugin release as well.

danowar2k commented 10 months ago

Thanks!