get_charset_collate(); $subscribers = $wpdb->prefix . 'advently_subscribers'; $opens = $wpdb->prefix . 'advently_opens'; dbDelta( "CREATE TABLE {$subscribers} ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, email varchar(190) NOT NULL, user_id bigint(20) unsigned DEFAULT NULL, created_at datetime NOT NULL, consent_at datetime DEFAULT NULL, ip_hash char(64) NOT NULL DEFAULT '', PRIMARY KEY (id), UNIQUE KEY email (email), KEY user_id (user_id) ) {$charset};" ); dbDelta( "CREATE TABLE {$opens} ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, calendar_start date NOT NULL, subscriber_id bigint(20) unsigned DEFAULT NULL, door tinyint(3) unsigned NOT NULL, coupon_id bigint(20) unsigned DEFAULT NULL, opened_at datetime NOT NULL, PRIMARY KEY (id), UNIQUE KEY subscriber_door (calendar_start,subscriber_id,door), KEY door (calendar_start,door) ) {$charset};" ); update_option( self::VERSION_OPTION, self::VERSION, false ); } public static function tables(): array { global $wpdb; return [ $wpdb->prefix . 'advently_subscribers', $wpdb->prefix . 'advently_opens' ]; } }