How can I recreate/regenerate the oc_filecache table? [SOLVE : Here is the schema for oc_filecache]

Hello,

I had a problem with my oc_filecache table being corrupt. I searched on how to fix this and, unfortunately, one of the first “solutions” that I found was “delete the table then recreate it”. I succeeded at the “delete the table” part, but I can’t find any information on how to recreate it…

Yes, I now know that I should have truncated.
I tried a few occ commands : “maintenance:repair”, “files:scan” and even “upgrade”, but none worked.

Can someone please tell me which command to run?
Or, give me the schema of their oc_filecache table so that I can create it in my database?

Thank you,

-MIke

P.S. I didn’t give any system info because I don’t know where to get it, since Nextcloud can’t run…

1 Like

occ files:scan --all -vvv should tell you what it is doing.

1 Like

Thanks for the reply :slight_smile:

I already ran files:scan, it just tells me that the table is missing… then it stops there.

Ah you did not empty one but rather delete it. OK then you have to recreate it fully with sql.

This is how my backup looks like using mysqldump. It’s from Nextcloud 17. It creates a new empty table with correct columns. occ files:scan --all -vvv should work now.

--
-- Table structure for table `oc_filecache`
--

DROP TABLE IF EXISTS `oc_filecache`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `oc_filecache` (
  `fileid` bigint(20) NOT NULL AUTO_INCREMENT,
  `storage` bigint(20) NOT NULL DEFAULT 0,
  `path` varchar(4000) COLLATE utf8mb4_bin DEFAULT NULL,
  `path_hash` varchar(32) COLLATE utf8mb4_bin NOT NULL DEFAULT '',
  `parent` bigint(20) NOT NULL DEFAULT 0,
  `name` varchar(250) COLLATE utf8mb4_bin DEFAULT NULL,
  `mimetype` bigint(20) NOT NULL DEFAULT 0,
  `mimepart` bigint(20) NOT NULL DEFAULT 0,
  `size` bigint(20) NOT NULL DEFAULT 0,
  `mtime` bigint(20) NOT NULL DEFAULT 0,
  `storage_mtime` bigint(20) NOT NULL DEFAULT 0,
  `encrypted` int(11) NOT NULL DEFAULT 0,
  `unencrypted_size` bigint(20) NOT NULL DEFAULT 0,
  `etag` varchar(40) COLLATE utf8mb4_bin DEFAULT NULL,
  `permissions` int(11) DEFAULT 0,
  `checksum` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
  PRIMARY KEY (`fileid`),
  UNIQUE KEY `fs_storage_path_hash` (`storage`,`path_hash`),
  KEY `fs_parent_name_hash` (`parent`,`name`),
  KEY `fs_storage_mimetype` (`storage`,`mimetype`),
  KEY `fs_storage_mimepart` (`storage`,`mimepart`),
  KEY `fs_storage_size` (`storage`,`size`,`fileid`),
  KEY `fs_mtime` (`mtime`)
) ENGINE=InnoDB AUTO_INCREMENT=727173 DEFAULT CHARSET=utf8mb4 COLLA
TE=utf8mb4_bin ROW_FORMAT=COMPRESSED;
/*!40101 SET character_set_client = @saved_cs_client */;
3 Likes

This seems to have worked! You are a life saver! Well… A server saver for sure!

Thank you so much for taking the time to create that schema for me!

-MIke

P.S. I was able to connect via the web, and Linux client. All seems good!

3 Likes

I’m glad to have helped :slight_smile:

THX for your help

1 Like

Nearly 2 years later and you saved my ass. Thank you!

1 Like