Activity app: OC_Activity table accidentally deleted (MariaDB)

Hello Nextclouders, this is my first post in the community forum.
Long story short, I accidentally deleted the Activity table (or tables? I do not even remember if they were one or two) with PhPMyAdmin. I do not know how to create a new one and which structure give to it. I am using MariaDB.

Thanks in advance for your attention.
Cheers.

I would try to uninstall and reinstall the activities app.

For the future: always have backups of your database :wink:.

If required, I can have a look at my table later. Do you use the latest Nextcloud 14?

Hi Michalng and thanks for your answer.
No, I am using Nextcloud 13.07.

How can I uninstall the activity app? In my browser admin interface I can just disable it (already tried to disable and renable, but it does not work). Should I just

rm -rf /var/www/nextcloud/apps/activity

?

Thanks.

Hi,
unfortunately uninstall and reinstall the activity app did not work (since it did not recreate oc_activity_table. Here are my logs:

Error while running background job (Doctrine\DBAL\Exception\TableNotFoundException): An exception occurred while executing 'SELECTamq_affecteduser, MIN(amq_latest_send) ASamq_trigger_timeFROMoc_activity_mqWHEREamq_latest_send< ? GROUP BYamq_affecteduserORDER BYamq_trigger_timeASC LIMIT 500' with params [1542361501]: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'owncloud.oc_activity_mq' doesn't exist

How can I create new empty table for the activity app? Can somebody help me with this, please?

Thanks.

Hi,

Same here - I had to drop the oc_activity table as it was corrupted and prevented MariaDB to start.
Can someone share the recreate query from a Nextcloud 22 DB backup?

Thanks!

I recovered it. Here’s the SQL command in case someone else needs it (Nextcloud 22):

--
-- Table structure for table `oc_activity`
--

DROP TABLE IF EXISTS `oc_activity`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `oc_activity` (
  `activity_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `timestamp` int(11) NOT NULL DEFAULT 0,
  `priority` int(11) NOT NULL DEFAULT 0,
  `type` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
  `user` varchar(64) COLLATE utf8mb4_bin DEFAULT NULL,
  `affecteduser` varchar(64) COLLATE utf8mb4_bin NOT NULL,
  `app` varchar(32) COLLATE utf8mb4_bin NOT NULL,
  `subject` varchar(255) COLLATE utf8mb4_bin NOT NULL,
  `subjectparams` longtext COLLATE utf8mb4_bin NOT NULL,
  `message` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
  `messageparams` longtext COLLATE utf8mb4_bin DEFAULT NULL,
  `file` varchar(4000) COLLATE utf8mb4_bin DEFAULT NULL,
  `link` varchar(4000) COLLATE utf8mb4_bin DEFAULT NULL,
  `object_type` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
  `object_id` bigint(20) NOT NULL DEFAULT 0,
  PRIMARY KEY (`activity_id`),
  KEY `activity_user_time` (`affecteduser`,`timestamp`),
  KEY `activity_filter_by` (`affecteduser`,`user`,`timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPRESSED;
/*!40101 SET character_set_client = @saved_cs_client */;
2 Likes

Thanks. As for some unknown reason my oc_activity got corrupted and so no db backup was successfull. the “create table” helped :slight_smile: