I am using Algolia extension in which algoliasearch_queue_archive is a table in which there isn’t a primary key present.
I tried adding primary key to the table using below db_schema.xml code
<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="algoliasearch_queue_archive">
<column xsi:type="int" name="archive_id" unsigned="true" nullable="false" identity="true" comment="Archive ID"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="archive_id"/>
</constraint>
</table>
</schema>
Now when I run setup:upgrade command, I see error
Notice: Undefined index: PK_ALGOLIASEARCH_QUEUE_ARCHIVE in
/var/www/html/myproject/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php
on line 4083
Here is the schema of the table
CREATE TABLE `algoliasearch_queue_archive` (
`pid` int unsigned DEFAULT NULL COMMENT 'PID',
`class` varchar(50) NOT NULL COMMENT 'class',
`method` text NOT NULL COMMENT 'Method',
`data` text NOT NULL COMMENT 'Data',
`error_log` text NOT NULL COMMENT 'Error Log',
`data_size` int unsigned DEFAULT NULL COMMENT 'Data Size',
`created_at` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT 'Date and time of job creation'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='Algoliasearch Queue Archive Table'
Can someone guide, how to add primary key to this table?