Database oc_cards corrupt

Hi all
im getting the following error during occ check
Base table or view not found: 1932 Table ‘nextcloud.oc_cards’ doesn’t exist in engine

i guess it is corrupt and i want to recreate the table in the database, does someone have the sql create syntax for this?
Thanks

Hello,
Don’t edit the database yourself… Try occ command before. You can find this here :
https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/occ_command.html#maintenance-commands-label
You can try :
sudo -u www-data php occ maintenance:repair
sudo -u www-data php occ db:add-missing-indices

If it doesnt work, look at this :

Good luck

thanks but occ maintenance:repair tells me the error above, i need to recreate the table oc_cards, not oc_file_locks, i just need the table layout

Hello, I did a mysqdump of my sql database and i found this in the backup :

--
-- Table structure for table `oc_cards`
--

DROP TABLE IF EXISTS `oc_cards`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `oc_cards` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `addressbookid` bigint(20) NOT NULL DEFAULT 0,
  `carddata` longblob DEFAULT NULL,
  `uri` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
  `lastmodified` bigint(20) unsigned DEFAULT NULL,
  `etag` varchar(32) COLLATE utf8mb4_bin DEFAULT NULL,
  `size` bigint(20) unsigned NOT NULL,
  `uid` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `cards_abid` (`addressbookid`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPRESSED;
/*!40101 SET character_set_client = @saved_cs_client */; 

It should works.
(I have mariadb)

1 Like

thanks! thats it. i fixed the issue :slight_smile:

Thank you bastien. :slightly_smiling_face:

What would be the equivalent for PostreSQL?

Seems like this was it:

DROP TABLE IF EXISTS oc_cards;
/* SQLINES DEMO *** cs_client     = @@character_set_client */;
/* SQLINES DEMO *** er_set_client = utf8 */;
-- SQLINES LICENSE FOR EVALUATION USE ONLY
CREATE SEQUENCE oc_cards_seq;

CREATE TABLE oc_cards (
  id bigint check (id > 0) NOT NULL DEFAULT NEXTVAL ('oc_cards_seq'),
  addressbookid bigint NOT NULL DEFAULT 0,
  carddata bytea DEFAULT NULL,
  uri varchar(255) DEFAULT NULL,
  lastmodified bigint check (lastmodified > 0) DEFAULT NULL,
  etag varchar(32) DEFAULT NULL,
  size bigint check (size > 0) NOT NULL,
  uid varchar(255) DEFAULT NULL,
  PRIMARY KEY (id)
)  ;

ALTER SEQUENCE oc_cards_seq RESTART WITH 4;
/* SQLINES DEMO *** er_set_client = @saved_cs_client */;

CREATE INDEX cards_abid ON oc_cards (addressbookid);