<?php
namespace Datacake\Core\Includes;
/**
 * Fired during plugin activation
 *
 * @link       http://www.datacake.com.br
 * @since      1.0.0
 *
 * @package    Datacake_core
 * @subpackage Datacake_core/includes
 */

/**
 * Fired during plugin activation.
 *
 * This class defines all code necessary to run during the plugin's activation.
 *
 * @since      1.0.0
 * @package    Datacake_core
 * @subpackage Datacake_core/includes
 * @author     Datacake <ajuda@datacake.com.br>
 */
class DatacakeCoreActivator {
	public static $config_name = 'datacake-isp-db-version';
	/**
	 * Short Description. (use period)
	 *
	 * Long Description.
	 *
	 * @since    1.0.0
	 */
	public static function activate() {
		global $wpdb;
		$db_version = get_option(self::$config_name, '0.0.0');
		if( version_compare( $db_version,	'1.0.0', '<' ) ) {
			require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
			$charset_collate = $wpdb->get_charset_collate();
			if( ! get_option(self::$config_name,null) ) {
				require_once(
					realpath(__DIR__.'/../Models/db/001Initial.php')
				);
			}
		}
		
	}
	/**
	 * Updating the theme.
	 *
	 * @since    1.1.1
	 */
	static function update(){
		global $wpdb;
		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
		$db_version = get_option(self::$config_name, '1.0.0');
		if( version_compare( $db_version,	'1.1.1', '<' ) ) {
            require_once(
				realpath(__DIR__.'/../Models/db/002ShortNameAndRedir.php')
			);
    	}
		if( version_compare( $db_version,	'1.1.2', '<' ) ) {
            require_once(
				realpath(__DIR__.'/../Models/db/003CityNeighborhood.php')
			);
    	}


	}


}
