Closed mohammad425 closed 1 year ago
Hey, @mohammad425 ๐
Thanks for reporting this and opening a PR; itโs much appreciated!
Iโve reproduced the error you mentioned. After reviewing your PR, Iโm ready to merge it into the codebase ๐
@mohammad425 Iโve merged this into the next
branch. Your changes will be included in the next release. Thanks for taking the time to open this PR ๐
Prior to this commit, when reactivating the plugin, a SQL error occurred due to the attempt to redefine a primary key. The error was specifically caused by the ALTER TABLE statement trying to change the primary key of the "pressidium_cookie_consents" table, which already existed in the database.
To resolve this issue, a check was implemented to verify the existence of the table before attempting any alterations. The new table_exists method was added to the codebase. Now, when the
create
method is called, it first checks if the target table already exists in the database. If it does, the method exits gracefully, avoiding any conflicting SQL statements.This modification ensures that the table is only created if it doesn't exist, preventing the "Multiple primary key defined" error on plugin reactivation.