Better action hook for creating table than after_switch_theme and switch_theme action hook

Ah I found it.

You can use after_setup_theme action hook. So it will be like

add_action('after_setup_theme', ['\Recruitment\recruitment', 'create_table']);

Updated Code

$theme = wp_get_theme();

if ( $theme->name == 'My THEME NAME' ) {

  global $wpdb;
  global $charset_collate;

  $sql = "CREATE TABLE IF NOT EXISTS ... $charset_collate;";

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

  add_option( 'ab_db_version', self::$db_version );

}

// in another file

add_action('after_switch_theme', ['\Recruitment\recruitment', 'create_table']);