• Resolved Compudata

    (@compudata)


    Hello,

    The following tables have no primary key:
    prefix_aws_cache
    prefix_aws_index

    For managed database clusters at DigitalOcean, this is a problem, since the primary key is required to exist on all tables for restoring, recovering, forking, etc: https://docs.digitalocean.com/products/databases/mysql/how-to/create-primary-keys/

    I noticed that to solve a migration issue a few months back, you had someone simply drop the tables and re-index, etc. Will this re-create the tables with a primary key? If not, would you consider adding a primary key to these tables during creation to accommodate the subset of your users who utilize databases such as DigitalOcean’s managed database clusters?

    Thanks in advance for your help.

Viewing 1 replies (of 1 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hi,

    For now you can use following code snippet to create table keys:

    add_action( 'aws_create_index_table', 'my_aws_create_index_table' );
    function my_aws_create_index_table() {
        global $wpdb;
        $table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
        $wpdb->query("
            ALTER TABLE {$table_name}
            ADD COLUMN <code>key</code> int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT FIRST;
        ");
    
        $table_name = $wpdb->prefix . AWS_CACHE_TABLE_NAME;
        $wpdb->query("
            ALTER TABLE {$table_name}
            ADD COLUMN <code>key</code> int(10) UNSIGNED PRIMARY KEY AUTO_INCREMENT FIRST;
        ");
    }

    After add it please reindex plugin table.

    Regards

Viewing 1 replies (of 1 total)
  • The topic ‘Primary Keys’ is closed to new replies.