public static function maybe_install_table( Table $table, \wpdb $wpdb = null ) {

		$wpdb = $wpdb ?: $GLOBALS['wpdb'];

		$installed = (int) get_option( $table->get_table_name( $wpdb ) . '_version', 0 );

		if ( $installed >= $table->get_version() ) {
			return false;
		}

		if ( $installed === 0 ) {
			if ( ! static::is_table_installed( $table, $wpdb ) ) {
				$prev = $wpdb->show_errors( false );
				$wpdb->query( $table->get_creation_sql( $wpdb ) );
				$wpdb->show_errors( $prev );

				if ( $wpdb->last_error ) {
					throw new Exception( $wpdb->last_error );
				}

				static::fire_plugin_event( $table, 'installed' );
			}
		} else {

			$update = $installed + 1;

			while ( $update <= $table->get_version() ) {

				if ( method_exists( $table, "v{$update}_schema_update" ) ) {
					$method = "v{$update}_schema_update";

					$table->{$method}( $wpdb, $installed );

					static::fire_plugin_event( $table, 'updated_schema', array( $update, $installed ) );
				}

				$update += 1;
			}

			static::fire_plugin_event( $table, 'updated' );
		}

		update_option( $table->get_table_name( $wpdb ) . '_version', $table->get_version() );

		return true;
	}