Load the outstanding migrations.

@return array
431540
private function loadMigrations()
    {
        // Load the migrations already performed

        $migrated = [];
        $rows = $this->db->table('_migrations')->select('name')->all();
        foreach ($rows as $row) {
            $migrated[] = $row['name'];
        }

        // Load the outstanding migrations

        $migrations = [];

        // read migrations from folder
        $files = [];
        list_files($files, $this->migrationPath, ['php']);
        foreach ($files as $file) {
            $name = basename($file, '.php');
            $migrations[$name] = $file;
        }

        // read migrations included by plugins
        $migrations = array_merge($migrations, $this->pluginMigrations());

        // remove migrations already performed
        foreach ($migrations as $name => $file) {
            if (in_array($name, $migrated)) {
                unset($migrations[$name]);
            }
        }

        return $migrations;
    }
1325902
public function up()
    {
        Schema::create('users_profiles', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id');
            $table->string('first_name', 80);
            $table->string('last_name', 80);
            $table->string('title', 16)->default(null);
            $table->string('gender', 16)->default(null);
            $table->string('picture', 120)->default(null);
            $table->date('date_of_birth')->default(null);
            $table->string('phone', 40)->default(null);
            $table->string('website', 80)->default(null);
            $table->string('timezone', 40)->default('UTC');
            $table->string('language', 40)->default('en_US');
            $table->string('security_questions_one', 80)->default(null);
            $table->string('security_questions_one_answer', 40)->default(null);
            $table->string('security_questions_two', 80)->default(null);
            $table->string('security_questions_two_answer', 40)->default(null);
            $table->timestamps();
            $table->charset = 'utf8';
            $table->collation = 'utf8_general_ci';
        });
    }
157450
public function up()
    {
        Schema::table('admin_menu', function (Blueprint $table) {
            $table->create();
            $table->increments('id');
            $table->integer('action_id');
            $table->integer('parent');
            $table->integer('order');
            $table->string('icon');
            $table->string('item_name');
            $table->string('item_desc')->nullable();
            $table->timestamps();
        });

        $date = new Carbon;

        DB::table('admin_menu')->insert(
            array(
                array(
                    'action_id' => 1,
                    'parent' => 0,
                    'order' => 1,
                    'icon' => 'fa fa-home',
                    'item_name' => 'Dashboard',
                    'item_desc' => '',
                    'created_at' => $date,
                    'updated_at' => $date
                ),
                array(
                    'action_id' => 5,
                    'parent' => 0,
                    'order' => 2,
                    'icon' => 'fa fa-file-text-o',
                    'item_name' => 'Pages',
                    'item_desc' => '',
                    'created_at' => $date,
                    'updated_at' => $date
                ),
                array(
                    'action_id' => 18,
                    'parent' => 0,
                    'order' => 3,
                    'icon' => 'fa fa-bars',
                    'item_name' => 'Menus',
                    'item_desc' => '',
                    'created_at' => $date,
                    'updated_at' => $date
                ),
                array(
                    'action_id' => 25,
                    'parent' => 0,
                    'order' => 4,
                    'icon' => 'fa fa-globe',
                    'item_name' => 'Site-wide Content',
                    'item_desc' => '',
                    'created_at' => $date,
                    'updated_at' => $date
                ),
                array(
                    'action_id' => 28,
                    'parent' => 0,
                    'order' => 5,
                    'icon' => 'fa fa-exchange',
                    'item_name' => 'Redirects',
                    'item_desc' => '',
                    'created_at' => $date,
                    'updated_at' => $date
                ),
                array(
                    'action_id' => 26,
                    'parent' => 0,
                    'order' => 6,
                    'icon' => 'fa fa-folder-open',
                    'item_name' => 'File Manager',
                    'item_desc' => '',
                    'created_at' => $date,
                    'updated_at' => $date
                ),
                array(
                    'action_id' => 39,
                    'parent' => 0,
                    'order' => 7,
                    'icon' => 'fa fa-user',
                    'item_name' => 'Users',
                    'item_desc' => '',
                    'created_at' => $date,
                    'updated_at' => $date
                ),
                array(
                    'action_id' => 43,
                    'parent' => 0,
                    'order' => 8,
                    'icon' => 'fa fa-bullhorn',
                    'item_name' => 'Roles',
                    'item_desc' => '',
                    'created_at' => $date,
                    'updated_at' => $date
                ),
                array(
                    'action_id' => 62,
                    'parent' => 0,
                    'order' => 9,
                    'icon' => 'fa fa-tint',
                    'item_name' => 'Theme',
                    'item_desc' => '',
                    'created_at' => $date,
                    'updated_at' => $date
                ),
                array(
                    'action_id' => 64,
                    'parent' => 0,
                    'order' => 9,
                    'icon' => 'fa fa-bluetooth-b',
                    'item_name' => 'Beacons',
                    'item_desc' => '',
                    'created_at' => $date,
                    'updated_at' => $date
                )
            )
        );
    }
164063
private function getOrganizeMigrationsModes() : array
    {
        $constPrefix = 'VERSIONS_ORGANIZATION_';
        $prefixLen   = strlen($constPrefix);
        $refClass    = new ReflectionClass('Doctrine\Migrations\Configuration\Configuration');
        $constsArray = $refClass->getConstants();
        $namesArray  = [];

        foreach ($constsArray as $key => $value) {
            if (strpos($key, $constPrefix) !== 0) {
                continue;
            }

            $namesArray[] = substr($key, $prefixLen);
        }

        return $namesArray;
    }
291560
public function up()
	{
		Schema::create('pages', function ($table) {

			$table->increments('id');

			$table->string('type')->default('');
			$table->string('name')->default('');

            $table->integer('parent_page_id')->default(0);
            $table->string('sub_page_order')->default('manual');
            $table->string('path')->default('');

            $table->integer('order')->default(0);

			$table->string('remote_id')->nullable(); // Used to mark any imported pages/content

			$table->integer('current_version')->default(1);

			$table->integer('is_trashed')->default(0);
			$table->integer('is_home')->default(0);

			$table->integer('created_by')->nullable();
			$table->integer('edited_by')->nullable();
			$table->timestamps();

		});

		Schema::create('pageversions', function ($table) {

			$table->increments('id');

			$table->integer('page_id');
			$table->integer('version');

            $table->text('slug')->nullable();

			$table->string('meta_page_title')->nullable();
			$table->text('meta_description')->nullable();

			$table->string('preview_key')->nullable();
			
			$table->string('status')->default('draft'); // draft/published/archived (maybe pending for sign off?)
            $table->boolean('is_hidden')->default(0);
            $table->boolean('is_hidden_navigation')->default(0);

			$table->timestamp('visible_from')->nullable();
			$table->timestamp('visible_to')->nullable();

			$table->string('publish_handler')->nullable();
			$table->text('publish_handler_data')->nullable();

            $table->string('template_identifier')->default('');
			$table->string('layout_identifier')->default('');

			$table->integer('created_by')->nullable();
			$table->integer('edited_by')->nullable();
			$table->timestamps();

		});

		Schema::create('pageattributes', function ($table) {

			$table->increments('id');
			$table->integer('page_version_id');

			$table->string('identifier')->default('');
			$table->string('type')->default('');
			$table->integer('order'); // Just so that the form matches the array order

			$table->text('attribute_data')->nullable(); // I think most attribute types can store everything they need in here..

            $table->index('page_version_id');
            $table->index('identifier');

        });

	}
1332825
public function up()
    {
        $connection = config('admin.database.connection') ?: config('database.default');

        $table = config('admin.extensions.config.table', 'admin_config');

        Schema::connection($connection)->create($table, function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('value');
            $table->text('description')->nullable();
            $table->timestamps();
        });
    }
954982
public function getMigrationsClasses()
    {
        $appFiles = $this->getMigrationsFiles();
        $classes = [];

        /* @var $component AppInterface */
        foreach ($appFiles as $appName => $migrationFiles) {
            $component = $this->orm->getComponent($appName);
            foreach ($migrationFiles as $migrationFile) {
                $className = ClassHelper::getClassFromFile($migrationFile);
                $foundClass = ClassHelper::classExists(
                    $className,
                    $component->getNamespace()
                );
                if (!$foundClass) {
                    throw new ClassNotFoundException(
                        sprintf(
                            'The class [ %2$s\\%1$s or \\%1$s ] '.
                            'could not be located',
                            $className,
                            $component->getNamespace()
                        )
                    );
                }
                $classes[$appName][] = $foundClass;
            }
        }

        return $classes;
    }
277444
public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->engine = 'InnoDB';

            $table->increments('id');
            $table->string('username');
            $table->string('password');
            $table->rememberToken();
            $table->string('email');
            $table->string('api_key');
            $table->boolean('active')->default(1);
            $table->tinyInteger('level')->default(2);
            $table->timestamps();

            $table->index('remember_token');
            $table->index('active');
            $table->unique('username');
            $table->unique('api_key');
            $table->unique('email');
        });
    }
1091251
protected function getNewMigrations()
    {
        $applied = [];
        foreach ($this->getMigrationHistory(null) as $class => $time) {
            $applied[trim($class, '\\')] = true;
        }

        $migrationPaths = [];
        if (is_array($this->migrationPath)) {
            foreach ($this->migrationPath as $path) {
                $migrationPaths[] = [$path, ''];
            }
        } elseif (!empty($this->migrationPath)) {
            $migrationPaths[] = [$this->migrationPath, ''];
        }
        foreach ($this->migrationNamespaces as $namespace) {
            $migrationPaths[] = [$this->getNamespacePath($namespace), $namespace];
        }

        $migrations = [];
        foreach ($migrationPaths as $item) {
            [$migrationPath, $namespace] = $item;
            if (!file_exists($migrationPath)) {
                continue;
            }
            $handle = opendir($migrationPath);
            while (($file = readdir($handle)) !== false) {
                if ($file === '.' || $file === '..') {
                    continue;
                }
                $path = $migrationPath . DIRECTORY_SEPARATOR . $file;
                if (preg_match('/^(m(\d{6}_?\d{6})\D.*?)\.php$/is', $file, $matches) && is_file($path)) {
                    $class = $matches[1];
                    if (!empty($namespace)) {
                        $class = $namespace . '\\' . $class;
                    }
                    $time = str_replace('_', '', $matches[2]);
                    if (!isset($applied[$class])) {
                        $migrations[$time . '\\' . $class] = $class;
                    }
                }
            }
            closedir($handle);
        }
        ksort($migrations);

        return array_values($migrations);
    }
234829
public function getMigratedVersions()
    {
        $this->createMigrationCollection();

        $cursor = $this->getCollection()->find();
        $versions = [];
        foreach ($cursor as $record) {
            $versions[] = $record['v'];
        }

        return $versions;
    }
134188
public function up()
    {
        // We need a better way of handling data migrations...
        $system = app(System::class);
        $prefix = $system->getTablePrefix();
        DB::update("INSERT INTO {$prefix}schedules (name, message, scheduled_at, created_at, updated_at) SELECT name, message, scheduled_at, created_at, updated_at FROM {$prefix}incidents WHERE scheduled_at IS NOT NULL");

        DB::table('incidents')->whereNotNull('scheduled_at')->delete();

        Schema::table('incidents', function (Blueprint $table) {
            $table->dropColumn('scheduled_at');
        });
    }
1266106
private function pluginMigrations()
    {
        $files = [];

        if (file_exists($this->pluginManifestOfMigrations)) {
            $basePath = base_path();
            /** @noinspection PhpIncludeInspection */
            $migrations = include $this->pluginManifestOfMigrations;
            foreach ($migrations as $name => $file) {
                $files[$name] = $basePath . DIRECTORY_SEPARATOR . $file;
            }
        }

        return $files;
    }
1181396
public static function load()
    {
        if (!extension_loaded('opencensus')) {
            trigger_error('opencensus extension required to load Laravel integrations.', E_USER_WARNING);
            return;
        }

        Eloquent::load();

        // Create a trace span for every template rendered
        // public function get($path, array $data = array())
        opencensus_trace_method(CompilerEngine::class, 'get', function ($scope, $path, $data) {
            return [
                'name' => 'laravel/view',
                'attributes' => [
                    'path' => $path
                ]
            ];
        });
    }
417202
public function getMigrations()
    {
        $path = $this['path'];

        $files = Filesystem::files($path);

        $migrations = new DataSet();

        foreach ($files as $file) {
            $ext = File::getExtension($file->getBasename());

            if ($ext !== 'php') {
                continue;
            }

            $name = $file->getBasename();

            list($id, $name) = explode('_', $name, 2);

            $mig = new Data();

            $mig['id']      = $id;
            $mig['version'] = $id;
            $mig['name']    = File::stripExtension($name);
            $mig['class']   = StringNormalise::toCamelCase(File::stripExtension($name));
            $mig['file']    = $file->getBasename();
            $mig['path']    = $file->getPathname();

            $migrations[$id] = $mig;
        }

        return $migrations;
    }
374978
public static function load()
    {
        if (!extension_loaded('opencensus')) {
            trigger_error('opencensus extension required to load Eloquent integrations.', E_USER_WARNING);
            return;
        }

        // public function getModels($columns = ['*'])
        opencensus_trace_method(Builder::class, 'getModels', function ($builder) {
            return [
                'name' => 'eloquent/get',
                'attributes' => [
                    'query' => $builder->toBase()->toSql()
                ],
                'kind' => Span::KIND_CLIENT
            ];
        });

        // protected function performInsert(Builder $query)
        opencensus_trace_method(Model::class, 'performInsert', function ($model, $query) {
            return [
                'name' => 'eloquent/insert',
                'attributes' => [
                    'query' => $query->toBase()->toSql()
                ],
                'kind' => Span::KIND_CLIENT
            ];
        });

        // protected function performUpdate(Builder $query)
        opencensus_trace_method(Model::class, 'performUpdate', function ($model, $query) {
            return [
                'name' => 'eloquent/update',
                'attributes' => [
                    'query' => $query->toBase()->toSql()
                ],
                'kind' => Span::KIND_CLIENT
            ];
        });

        // public function delete()
        opencensus_trace_method(Model::class, 'delete', function ($model) {
            return [
                'name' => 'eloquent/delete',
                'kind' => Span::KIND_CLIENT
            ];
        });
    }
429448
public function up()
    {
        Schema::create('roles', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('key')->unique();
            $table->timestamps();
        });

        Role::create([
            'name' => 'Administrator',
            'key' => 'admin'
        ]);

        Role::create([
            'name' => 'User',
            'key' => 'user'
        ]);

        Role::create([
            'name' => 'Guest',
            'key' => 'guest'
        ]);

        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('role_id');
            $table->string('avatar')->nullable();
            $table->string('name')->nullable();
            $table->string('email')->unique();
            $table->string('password');
            $table->boolean('active')->default(false);
            $table->string('activation', 32)->nullable();
            $table->timestamps();

            $table->foreign('role_id')->references('id')->on('roles');
        });

        $this->config();
    }
1318664
private function getFileFields() : array
    {
        $config = new ModuleConfig(ConfigType::MIGRATION(), $this->table->getAlias());
        $config = json_encode($config->parse());
        if (false === $config) {
            return [];
        }

        $fields = json_decode($config, true);

        if (empty($fields)) {
            return [];
        }

        $fields = array_filter($fields, function ($params) {
            return in_array($params['type'], self::FIELD_TYPES);
        });

        return array_keys($fields);
    }