get_charset_collate(); dbDelta( "CREATE TABLE {$wpdb->prefix}joinery_rules ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, name varchar(190) NOT NULL, status varchar(20) NOT NULL DEFAULT 'active', priority int(11) NOT NULL DEFAULT 10, exclusive tinyint(1) NOT NULL DEFAULT 0, conditions longtext NOT NULL, actions longtext NOT NULL, created_at datetime NOT NULL, updated_at datetime NOT NULL, PRIMARY KEY (id), KEY status_priority (status, priority) ) $charset;" ); dbDelta( "CREATE TABLE {$wpdb->prefix}joinery_wallet_ledger ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, customer_id bigint(20) unsigned NOT NULL, amount decimal(19,4) NOT NULL, currency char(3) NOT NULL, source varchar(64) NOT NULL, order_id bigint(20) unsigned DEFAULT NULL, note varchar(255) NOT NULL DEFAULT '', expires_at datetime DEFAULT NULL, created_at datetime NOT NULL, PRIMARY KEY (id), KEY customer_currency (customer_id, currency), KEY order_id (order_id) ) $charset;" ); update_option( self::OPTION, self::DB_VERSION ); } }