Migrate::install PHP Method

install() public method

Installs the schema up to the last version
public install ( ) : void
return void Outputs a report of the installation
    public function install()
    {
        $files = glob($this->migrations_path . "*" . EXT);
        $file_count = count($files);
        for ($i = 0; $i < $file_count; $i++) {
            // Mark wrongly formatted files as FALSE for later filtering
            $name = basename($files[$i], EXT);
            if (!preg_match('/^\\d{3}_(\\w+)$/', $name)) {
                $files[$i] = FALSE;
            }
        }
        $migrations = array_filter($files);
        if (!empty($migrations)) {
            sort($migrations);
            $last_migration = basename(end($migrations));
            // Calculate the last migration step from existing migration
            // filenames and procceed to the standard version migration
            $last_version = substr($last_migration, 0, 3);
            return $this->version(intval($last_version, 10));
        } else {
            $this->error = $this->_ci->lang->line("no_migrations_found");
            return 0;
        }
    }

Usage Example

Example #1
0
	public static function install()
	{
		\Migrate::install();
	}