Show migration infomation.

@param \Jumilla\Versionia\Laravel\Migrator $migrator
429045
protected function showMigrations(Migrator $migrator)
    {
        $this->line('<comment>Migrations</comment>');

        $groups = $migrator->migrationGroups();

        if (count($groups) > 0) {
            // get [$group => $items]
            $installed_migrations = $migrator->installedMigrationsByDesc();

            foreach ($groups as $group) {
                // [$items] to [$installed_versions]
                $installed_versions = $installed_migrations->get($group, collect())->pluck('version');

                // [$versions] to $latest_version
                $latest_installed_version = $installed_versions->get(0, Migrator::VERSION_NULL);

                // enum definition
                foreach ($migrator->migrationVersionsByDesc($group) as $version => $class) {
                    $installed = $installed_versions->contains($version);

                    if ($version === $latest_installed_version) {
                        $mark = '*';
                    } else {
                        $mark = $installed ? '-' : ' ';
                    }

                    if (!class_exists($class)) {
                        $this->line("{$mark} <info>[{$group}/{$version}]</info> <error>{$class}</error>");
                        $this->line('');
                        $this->error('Error: Class not found.');
                        continue;
                    }

                    $migration = new $class();

                    if (!$migration instanceof Migration) {
                        $this->line("{$mark} <info>[{$group}/{$version}]</info> <error>{$class}</error>");
                        $this->line('');
                        $this->error('Error: Must inherit from class "Illuminate\Database\Migrations\Migration".');
                        continue;
                    }

                    $this->line("{$mark} <info>[{$group}/{$version}]</info> {$class}");
                }

                $this->line('');
            }
        } else {
            $this->info('Nothing.');
            $this->line('');
        }
    }
913170
public function handle(Migrator $migrator)
    {
        if (!$this->confirmToProceed()) {
            return;
        }

        $seed = $this->argument('name') ?: $migrator->defaultSeed();

        if (!$seed) {
            $this->error('Default seed is not defined.');

            return;
        }

        $class = $migrator->seedClass($seed);

        if (!$class) {
            $this->error("Seed '$seed' is not defined.");

            return;
        }

        $this->infoSeedRun($seed, $class);

        $seeder = new $class();

        $seeder->setCommand($this)->run();
    }
1035568
public function showMigratingInfo($output, $level = 0)
    {
        $output->info(
            str_repeat("_",$level) . 'Migrating ' . class_basename($this) . ' ('. $this->id . ' | ' . $this->periodid
            . ') | Study ' . $this->study->name . ' ('. $this->study->id .
            ') | Course ' . $this->course->name . ' ('. $this->course->id .
            ') | Group ' . $this->group->name . ' ('. $this->group->id .
            ') | Person ' . $this->person->name . ' ('. $this->person->id .
            ') ...'
        );
    }
932165
public function write(string $identifier, MigrationList $executedMigrations): void
    {
        $exchange = $this->settings['exchange'];
        $client = $this->connector->getConnection();
        $uri = sprintf('/api/bindings/%1$s/e/%2$s/e/%2$s', $this->getVhost(), $exchange);

        // delete existing migration list entries before rewriting
        foreach ($this->loadMigrations() as $migration) {
            $client->delete($uri.'/'.$migration['properties_key']);
        }

        foreach ($executedMigrations as $migration) {
            $client->post($uri, [
                'body' => json_encode([
                    'routing_key' => $identifier,
                    'arguments' => $migration->toNative()
                ])
            ]);
        }
    }
193830
protected function migrateTeachers()
    {
        $this->output->info('### Migrating teachers ###');
        foreach ($this->teachers() as $teacher) {
            $this->showMigratingInfo($teacher, 1);
            $this->output->info('  email: ' . $teacher->email);
            $this->migrateTeacher($teacher);
        }
        $this->output->info(
            '### END Migrating teachers. Migrated ' . count($this->teachers()) .  ' teachers   ###');
    }
1321267
protected function saveMigrationFile(string $filePath, string $migration): void
    {
        $this->output->writeln(sprintf('Generate migration file: %s', $filePath));
        file_put_contents($filePath, $migration);
    }
229905
protected function outputMigrationList(array $migrations): void
	{
		$tableBody = [];

		foreach($migrations as $migration)
		{
			$name = $migration->version;

			if(!empty($migration->package))
			{
				$name .= ' (' . $migration->package . ')';
			}

			$description = $this->resolve($migration)->getDescription();

			$tableBody[] = [$name, $description];
		}

		$this->table(['Migration', 'Description'], $tableBody);
	}
1238385
public function execute( )
    {
        $this->doAction( self::ON_BEFORE_MIGRATE_CMD_EXECUTE_ACTION );
        
        if ( NULL === $this->migrator )
        {
            throw new MigrationException( 'You must set the migrator before executing this command.' );
        }
        
        $verbose   = self::getOption( $this, 'verbose' )->value;
        
        $direction = self::getOption( $this, 'direction' )->value;
        $levels    = self::getOption( $this, 'levels' )->value;
        
        $this->migrator->verbose = $verbose;
        
        switch( $direction )
        {
            case 'up':
                $this->migrator->migrateUp( $levels );
                break;
            
            case 'down':
                $this->migrator->migrateDown( $levels );
                break;
            
            default:
                // do nothing
                break;
        }
        
        $this->doAction( self::ON_AFTER_MIGRATE_CMD_EXECUTE_ACTION );
    }
688988
protected function callMigration($resource)
    {
        $migrationName = $this->getMigrationName($resource);

        if ($this->confirm("Do you want me to create a '$migrationName' migration and schema for this resource? [yes|no]"))
        {
            $this->call('generate:migration', [
                'migrationName' => $migrationName,
                '--fields' => $this->option('fields')
            ]);
        }
    }
1086179
protected function registerMigrationService(): void
    {
        $config = $this->app['config'];
        $config->set('database.migrations', $config->get('database.migrations') ?: 'migrations');
        $this->app->register(\Illuminate\Database\MigrationServiceProvider::class);

        $this->app->alias(
            'migration.repository',
            \Illuminate\Database\Migrations\MigrationRepositoryInterface::class
        );

        $this->app->singleton(
            'migrator',
            function ($app) {
                $repository = $app['migration.repository'];

                return new Migrator($repository, $app['db'], $app['files']);
            }
        );

        $this->app->alias(
            'migrator',
            \Illuminate\Database\Migrations\Migrator::class
        );
    }
1096138
private function publishMigrations($register)
    {
        // read migrations from folder
        $migrationPath = $this->path . '/migrations';
        if (!file_exists($migrationPath)) {
            return;
        }
        $files = [];
        list_files($files, $migrationPath, ['php']);

        // update manifest
        $manifest = $this->getManifest('migrations');
        /** @noinspection PhpIncludeInspection */
        $list = file_exists($manifest) ? include $manifest : [];
        $basePathLength = strlen(base_path()) + 1;
        foreach ($files as $file) {
            $name = basename($file, '.php');
            if ($register) {
                $list[$name] = substr($file, $basePathLength);
            }
            else {
                unset($list[$name]);
            }
        }
        $this->saveArray($manifest, $list);
    }
218322
protected function writeMigrations()
    {
        $files = $this->migrator->create($this->options);

        foreach ($files as $file) {
            $path = pathinfo($file, PATHINFO_FILENAME);
            $this->line("      <fg=green;options=bold>create</fg=green;options=bold>  $path");
        }

        $this->composer->dumpAutoloads();
    }
10913
public function migrate($migrationName) {
		$this->createTable();
		$this->db->dal()->into('_migrations')->insert(['name'=>$migrationName, 'migrated'=>date('Y-m-d H:i:s')]);
	}
571429
public function handle(Migrator $migrator)
    {
        if (!$this->confirmToProceed()) {
            return;
        }

        $migrator->makeLogTable();

        $this->doRefresh($migrator);

        $seed = $this->option('seed');

        if ($seed) {
            $this->call('database:seed', ['name' => $seed, '--force' => true]);
        }
    }
338818
protected function migrateTimeslots()
    {
        $this->output->info('### Migrating timeslots ###');
        foreach ($this->timeslots() as $timeslot) {
            $timeslot->showMigratingInfo($this->output,1);
            $this->migrateTimeslot($timeslot);
        }
        $this->output->info('### END OF Migrating timeslots ###');
    }
502893
protected function runMigration($migration, $method)
    {
        $callback = function () use ($migration, $method) {
            if (method_exists($migration, $method)) {
                $migration->{$method}();
            }
        };

        $callback();
    }
1180198
public function getFormattedMigrationStatus($showMigrations = false, $showDescriptions = false)
    {
        $statusInformation = $this->getMigrationStatus();
        $output = PHP_EOL . '<info>==</info> Configuration' . PHP_EOL;

        foreach ($statusInformation as $name => $value) {
            if ($name == 'New Migrations') {
                $value = $value > 0 ? '<question>' . $value . '</question>' : 0;
            }
            if ($name == 'Executed Unavailable Migrations') {
                $value = $value > 0 ? '<error>' . $value . '</error>' : 0;
            }
            $output .= '   <comment>></comment> ' . $name . ': ' . str_repeat(' ', 35 - strlen($name)) . $value . PHP_EOL;
        }

        if ($showMigrations) {
            $configuration = $this->getMigrationConfiguration();

            $executedMigrations = $configuration->getMigratedVersions();
            $availableMigrations = $configuration->getAvailableVersions();
            $executedUnavailableMigrations = array_diff($executedMigrations, $availableMigrations);
            if ($migrations = $configuration->getMigrations()) {
                $docCommentParser = new DocCommentParser();

                $output .= PHP_EOL . ' <info>==</info> Available Migration Versions' . PHP_EOL;

                /** @var Version $version */
                foreach ($migrations as $version) {
                    $packageKey = $this->getPackageKeyFromMigrationVersion($version);
                    $croppedPackageKey = strlen($packageKey) < 30 ? $packageKey : substr($packageKey, 0, 29) . '~';
                    $packageKeyColumn = ' ' . str_pad($croppedPackageKey, 30, ' ');
                    $isMigrated = in_array($version->getVersion(), $executedMigrations);
                    $status = $isMigrated ? '<info>migrated</info>' : '<error>not migrated</error>';
                    $migrationDescription = '';
                    if ($showDescriptions) {
                        $migrationDescription = str_repeat(' ', 2) . $this->getMigrationDescription($version, $docCommentParser);
                    }
                    $formattedVersion = $configuration->getDateTime($version->getVersion());

                    $output .= '    <comment>></comment> ' . $formattedVersion .
                        ' (<comment>' . $version->getVersion() . '</comment>)' . $packageKeyColumn .
                        str_repeat(' ', 2) . $status . $migrationDescription . PHP_EOL;
                }
            }

            if (count($executedUnavailableMigrations)) {
                $output .= PHP_EOL . ' <info>==</info> Previously Executed Unavailable Migration Versions' . PHP_EOL;
                foreach ($executedUnavailableMigrations as $executedUnavailableMigration) {
                    $output .= '    <comment>></comment> ' . $configuration->getDateTime($executedUnavailableMigration) .
                        ' (<comment>' . $executedUnavailableMigration . '</comment>)' . PHP_EOL;
                }
            }
        }

        return $output;
    }