作者:lihuibi
项目:notejam_blin
protected function execute(InputInterface $input, OutputInterface $output)
{
$capsule = app('capsule');
$connectionResolver = $capsule->getDatabaseManager();
$repository = new DatabaseMigrationRepository($connectionResolver, 'migrations');
if (!$repository->repositoryExists()) {
$repository->createRepository();
}
$migrator = new Migrator($repository, $connectionResolver, new Filesystem());
return $migrator->run(__DIR__ . '/../database/migrations');
}
作者:yusukezz
项目:migrato
public function resolve($file)
{
/* @var $class \Consolet\Migrator\Migration */
$class = parent::resolve($file);
$class::setSchemaOnce($this->resolveConnection(null)->getSchemaBuilder());
return $class;
}
作者:stilla
项目:databas
/**
* Returns a new TenantMigrator instance.
*
* @param MigrationRepositoryInterface $repository
* @param Resolver $resolver
* @param Filesystem $files
* @param TenantManager $manager
*/
public function __construct(MigrationRepositoryInterface $repository, Resolver $resolver, Filesystem $files, TenantManager $manager)
{
$this->manager = $manager;
// There is nothing special about the TenantMigrationResolver class, so let's just new up one.
$this->tenantMigrationResolver = new TenantMigrationResolver();
parent::__construct($repository, $resolver, $files);
}
作者:dadley
项目:lvpres
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$config = (require __DIR__ . '/../config.php');
$capsule = new Manager();
$capsule->addConnection($config);
$capsule->bootEloquent();
Schema::setConnection($capsule->getConnection('default'));
DB::setConnection($capsule->getConnection('default'));
// run the migrations
$migration_repo = new DatabaseMigrationRepository(Model::getConnectionResolver(), 'migrations');
if (!$migration_repo->repositoryExists()) {
$migration_repo->createRepository();
}
$migrator = new Migrator($migration_repo, Model::getConnectionResolver(), new Filesystem());
$migrator->rollback();
$migrator->run(__DIR__ . '/../../src/migrations');
static::loadFixtures();
}
作者:kiasak
项目:vexillu
public function execute(InputInterface $input, OutputInterface $output)
{
$migrationsPath = APP_ROOT . 'db/migrations/';
$c = $this->app->container();
$migrationsTableName = 'migrations';
$dbResolver = $c['database.manager']->getDatabaseManager();
$filesystem = new Filesystem();
// Get the database migrations repository (create if not existant)
$repository = new MigrationRepo($dbResolver, $migrationsTableName);
if (!$repository->repositoryExists()) {
$repository->createRepository();
}
// Run!
$migrator = new Migrator($repository, $dbResolver, $filesystem);
$migrator->run($migrationsPath);
// Show notes
foreach ($migrator->getNotes() as $note) {
$output->writeln(preg_replace('(<[a-zA-Z/]+>)', '', $note));
}
$output->writeln('');
$output->writeln('Migrated!');
}
作者:DavidIWilso
项目:site
/**
* Merge migrator operation notes.
*
* @param \Illuminate\Database\Migrations\Migrator $migrator
*
* @return void
*/
protected function mergeMigratorNotes(BaseMigrator $migrator)
{
$this->notes = array_merge($this->notes, $migrator->getNotes());
}
作者:MarkVaugh
项目:illuminate
/**
* Construct an instance of a NamespacedMigrator.
*
* @param MigrationRepositoryInterface $repository
* @param Resolver $resolver
* @param Filesystem $files
* @param string $namespace
*/
public function __construct(MigrationRepositoryInterface $repository, Resolver $resolver, Filesystem $files, $namespace = '')
{
parent::__construct($repository, $resolver, $files);
$this->namespace = $namespace;
}
作者:notad
项目:framewor
/**
* Migrator constructor.
*
* @param \Illuminate\Container\Container $container
* @param \Illuminate\Database\Migrations\MigrationRepositoryInterface $repository
* @param \Illuminate\Database\ConnectionResolverInterface $resolver
* @param \Illuminate\Filesystem\Filesystem $files
*/
public function __construct(Container $container, MigrationRepositoryInterface $repository, Resolver $resolver, Filesystem $files)
{
$this->container = $container;
parent::__construct($repository, $resolver, $files);
}
作者:hochan
项目:Bootsoft-Bowlin
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
$this->migrator->setConnection($this->input->getOption('database'));
$pretend = $this->input->getOption('pretend');
while ($this->migrator->rollback($this->output, $pretend)) {
}
}
作者:EnmanuelCod
项目:backend-larave
/**
* Prepare the migration database for running.
*
* @return void
*/
protected function prepareDatabase()
{
$this->migrator->setConnection($this->input->getOption('database'));
if (!$this->migrator->repositoryExists()) {
$options = ['--database' => $this->input->getOption('database')];
$this->call('migrate:install', $options);
}
}
作者:hochan
项目:Bootsoft-Bowlin
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
$this->migrator->setConnection($this->input->getOption('database'));
$package = $this->input->getOption('package') ?: 'application';
// The pretend option can be used for "simulating" the migration and grabbing
// the SQL queries that would fire if the migration were to be run against
// a database for real, which is helpful for double checking migrations.
$pretend = $this->input->getOption('pretend');
$path = $this->getMigrationPath();
$this->migrator->run($this->output, $package, $path, $pretend);
}
作者:defra9
项目:levecchiecredenze.i
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
$this->migrator->setConnection($this->input->getOption('database'));
$pretend = $this->input->getOption('pretend');
$this->migrator->rollback($pretend);
// Once the migrator has run we will grab the note output and send it out to
// the console screen, since the migrator itself functions without having
// any instances of the OutputInterface contract passed into the class.
foreach ($this->migrator->getNotes() as $note) {
$this->output->writeln($note);
}
}
作者:caffeinate
项目:module
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
if (!$this->confirmToProceed()) {
return;
}
$this->migrator->setConnection($this->option('database'));
$paths = $this->getMigrationPaths();
$this->migrator->rollback($paths, ['pretend' => $this->option('pretend'), 'step' => (int) $this->option('step')]);
foreach ($this->migrator->getNotes() as $note) {
$this->output->writeln($note);
}
}
作者:mark8609
项目:laravel-framewor
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
if (!$this->confirmToProceed()) {
return;
}
$this->migrator->setConnection($this->option('database'));
$this->migrator->rollback($this->getMigrationPaths(), ['pretend' => $this->option('pretend'), 'step' => (int) $this->option('step')]);
// Once the migrator has run we will grab the note output and send it out to
// the console screen, since the migrator itself functions without having
// any instances of the OutputInterface contract passed into the class.
foreach ($this->migrator->getNotes() as $note) {
$this->output->writeln($note);
}
}
作者:singularity32
项目:Art
/**
* Run "down" a migration instance. (Overridden)
*
* @param object $migration
* @param bool $pretend
* @return void
*/
protected function runDown($migration, $pretend)
{
$migrations = [$migration->migration];
// Retrieve migration path and throw exception if it doesn't exist
$path = $this->getMigrationPath(true);
$this->requireFiles($path, $migrations);
parent::runDown($migration, $pretend);
}
作者:arcanede
项目:modul
/**
* Prepare the migration database for running.
*/
private function prepareDatabase()
{
if ($database = $this->getStringOption('database')) {
$this->migrator->setConnection($database);
}
if (!$this->migrator->repositoryExists()) {
$this->call('migrate:install', ['--database' => $database]);
}
}
作者:cloud5idea
项目:appki
/**
* Run the migration reset for the specified module.
*
* @param string $slug
* @return mixed
*/
protected function reset($slug)
{
$this->migrator->setconnection($this->input->getOption('database'));
$pretend = $this->input->getOption('pretend');
$migrationPath = $this->getMigrationPath($slug);
$migrations = $this->migrator->getMigrationFiles($migrationPath);
if (count($migrations) == 0) {
return $this->error('Nothing to rollback.');
}
// We need to reverse these migrations so that they are "downed" in reverse
// to what they run on "up". It lets us backtrack through the migrations
// and properly reverse the entire database schema operation that originally
// ran.
foreach ($migrations as $migration) {
$this->info('Migration: ' . $migration);
$this->runDown($slug, $migration, $pretend);
}
}
作者:kreitj
项目:l4-schemad-migration
public function run($path, $pretend = false)
{
parent::run($path, $pretend);
$key = Config::get('database.default');
$database = Config::get('database.connections.' . $key . '.database');
$this->note('<info>Generating schema for: ' . $database . '</info>');
$builder = new Builder();
$builder->convert($database);
$builder->write();
}
作者:artesao
项目:migrato
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
if (!$this->confirmToProceed()) {
return;
}
$this->migrator->setConnection($this->input->getOption('database'));
if (!$this->migrator->repositoryExists()) {
$this->output->writeln('<comment>Migration table not found.</comment>');
return;
}
$pretend = $this->input->getOption('pretend');
$this->migrator->reset($pretend);
// Once the migrator has run we will grab the note output and send it out to
// the console screen, since the migrator itself functions without having
// any instances of the OutputInterface contract passed into the class.
foreach ($this->migrator->getNotes() as $note) {
$this->output->writeln($note);
}
}
作者:davidhemphil
项目:framewor
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
if (!$this->confirmToProceed()) {
return;
}
$this->migrator->setConnection($this->option('database'));
// First, we'll make sure that the migration table actually exists before we
// start trying to rollback and re-run all of the migrations. If it's not
// present we will just bail out with a info message for the developer.
if (!$this->migrator->repositoryExists()) {
return $this->comment('Migration table not found.');
}
$this->migrator->reset($this->getMigrationPaths(), $this->option('pretend'));
// Once the migrator has run we will grab the note output and send it out to
// the console screen, since the migrator itself functions without having
// any instances of the OutputInterface contract passed into the class.
foreach ($this->migrator->getNotes() as $note) {
$this->output->writeln($note);
}
}