sql – WordPress is not creating table in database after activating plugin,

Question

I struggled with this a long time! Can anyone help me?
My plugin is not creating a database table once activated. The following code is in the main plugin file.

function woocq_activate() {

    global $wpdb;

    $table_name = $wpdb->prefix . 'woocq';

    $sql = "CREATE TABLE $table_name (
        id MEDIUMINT(9) NOT NULL AUTO_INCREMENT,
        name VARCHAR NOT NULL,
        message TEXT NOT NULL,
        question_id INT NOT NULL,
        product_id INT DEFAULT NULL,
        timestamp BIGINT NOT NULL,
        PRIMARY KEY  (id)
    );";

    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    dbDelta( $sql );
    
}
register_activation_hook( __FILE__, 'woocq_activate' );

Thank you in advance!

0
Mushy 3 months 2022-05-19T12:39:03-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse