Can't find out why dbDelta dosen't create my table

I have a function which needs to create a new table an d i can't see for the life of me why it dosen't create the table:

function afdv_create_delivery_table ( $id ){

    global $wpdb;

    $charset_collate = $wpdb-get_charset_collate();

    //table name composed of db prefix + delivery + company ID
    $table_name = $wpdb-prefix . delivery_ . $id;

    $sql = CREATE TABLE $table_name (
      id int(10) unsigned NOT NULL AUTO_INCREMENT,
      userId int(10) NOT NULL,
      plati DECIMAL(10,2) NOT NULL,
      incasariCash DECIMAL(10,2) NOT NULL,
      incasariPvo DECIMAL(10,2) NOT NULL,
      incasariTransfer DECIMAL(10,2) NOT NULL,
      incasariOnline DECIMAL(10,2) NOT NULL,
      balanta DECIMAL(10,2) NOT NULL,
      transportIncasat DECIMAL(10,2) NOT NULL,
      bacsis DECIMAL(10,2) NOT NULL,
      sold DECIMAL(10,2) NOT NULL,
      cardId varchar(255) DEFAULT NULL,
      walletId varchar(255) DEFAULT NULL,
      data DATETIME default '0000-00-00 00:00:00' NOT NULL,
      terminalId varchar(255) DEFAULT NULL,
      transactionType int(10) DEFAULT NULL,
      companyId int(10) DEFAULT NULL,
      messageId varchar(255) DEFAULT NULL,
      dataModificare DATETIME default '0000-00-00 00:00:00' NOT NULL,
      paired int(10) NOT NULL,
      createdBy int(10) NOT NULL,
      PRIMARY KEY  (id),
      INDEX idx_card (cardId),
      INDEX idx_wallet (walltId),
      INDEX idX_terminal (terminalId)
    ) $charset_collate;;

    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );

    return dbDelta( $sql, true );
}

I tryied changing INDEX to KEY, changing all the int to INT, lower case for all columns names. I can't see what is wrong. I get the message that table was created but the table is not present in the database.

Any help appreciated!

Thanks!

EDIT: OP Found it.

Topic dbdelta wpdb Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.