Удалить Миграцию из базы

@param Migration $migration
191482
public function delete(Migration $migration)
    {
        if ($migration->isNew()) {
            throw new \InvalidArgumentException(__METHOD__.": Expected NOT NEW migration");
        }
        $this->adapter->execute(sprintf("DELETE FROM {$this->tableName} WHERE id='%d'", $migration->getId()));
    }
470204
public function remove($migrationName) {
		$list = $this->getList(false);
		unset($list[$migrationName]);
		$this->writeMigrations($list);
	}
961720
public function forget($name = '')
    {

        $filePath = FacadeMigration::createName($name);
        if ($this->file->exists($filePath)) {
            $this->file->delete($filePath);
            $this->info(sprintf('%s migration succesfully removed in %s', $name, $filePath));
        } else {
            $this->error(sprintf('%s migration could not removed in %s, file not exists', $name,
                $filePath));
        }
    }
1101162
protected function extract(string $migration): array
    {
        if (strpos($migration, '\\') === false) {
            $file = Yii::getAlias($this->migrationPath . DIRECTORY_SEPARATOR . $migration . '.php');

            if (!file_exists($file)) {
                throw new ErrorException("File '{$file}' can not be found! Check migration history table.");
            }

            require_once $file;
        }

        $subject = new $migration;
        $subject->db = $this->db;
        $subject->up();

        return $subject->changes;
    }
1210629
public function cleanup()
    {
        if ($this->option('force')) {
            $this->deleteDirs();
        } elseif ($this->confirm('Delete all subdirectories in migrations folder?', true)) {
            $this->deleteDirs();
        }
    }
515070
public function addMigration(SQLMigration $migration) {
		if (!$migration instanceof MySQLMigration) {
			throw new InvalidMigrationType(\get_class($migration));
		}
		$this->migrations[\get_class($migration)] = $migration;
	}
1181659
protected function runMigration($migration, $method)
    {
        $connection = $this->resolveConnection(
            $migration->getConnection()
        );

        $callback = function () use ($migration, $method) {
            if (method_exists($migration, $method)) {
                $migration->{$method}();
            }
        };

        $this->getSchemaGrammar($connection)->supportsSchemaTransactions()
            && $migration->withinTransaction
                    ? $connection->transaction($callback)
                    : $callback();
    }
1078562
public function migrateDown()
    {
        Schema::table('tddd_runs', function (Blueprint $table) {
            $table->dropColumn('screenshots');
            $table->text('png')->nullable();
        });
    }
741852
protected function processMigration(&$index, array $migrations, Migration $migration)
    {
        if (in_array($migration->getStatus(), [Migration::STATUS_MIGRATED, Migration::STATUS_RECURSIVE_FOREIGN_KEY], true)) {
            return;
        }
        $migration->setStatus(Migration::STATUS_IN_PROGRESS);

        // Check foreign keys
        $tableNames = $migration->getTable()->getForeignTableNames();
        foreach ($tableNames as $tableName) {
            if ($migration->getTable()->getTableName() === $tableName) {
                continue;
            }

            // Check recursive foreign key
            if (isset($migrations[$tableName]) && $migrations[$tableName]->getStatus() === Migration::STATUS_IN_PROGRESS) {
                $migration->setStatus(Migration::STATUS_RECURSIVE_FOREIGN_KEY);
                continue;
            }

            $this->processMigration($index, $migrations, $migrations[$tableName]);
        }

        $migration->writeTableOut($index, $this->output, $this->option('force'));

        if ($migration->getStatus() !== Migration::STATUS_RECURSIVE_FOREIGN_KEY) {
            $migration->setStatus(Migration::STATUS_MIGRATED);
        }

        $index++;
    }
431888
public function resumeMigration(Migration $migration, $useTransaction = true)
    {
        if ($migration->status != Migration::STATUS_SUSPENDED) {
            throw new \Exception("Can not resume ".$this->getEntityName($migration)." '{$migration->name}': it is not in suspended status");
        }

        $migrationDefinitions = $this->getMigrationsDefinitions(array($migration->path));
        if (!count($migrationDefinitions)) {
            throw new \Exception("Can not resume ".$this->getEntityName($migration)." '{$migration->name}': its definition is missing");
        }

        $defs = $migrationDefinitions->getArrayCopy();
        $migrationDefinition = reset($defs);

        $migrationDefinition = $this->parseMigrationDefinition($migrationDefinition);
        if ($migrationDefinition->status == MigrationDefinition::STATUS_INVALID) {
            throw new \Exception("Can not resume ".$this->getEntityName($migration)." '{$migration->name}': {$migrationDefinition->parsingError}");
        }

        // restore context
        $this->contextHandler->restoreCurrentContext($migration->name);

        if (!isset($this->migrationContext[$migration->name])) {
            throw new \Exception("Can not resume ".$this->getEntityName($migration)." '{$migration->name}': the stored context is missing");
        }
        $restoredContext = $this->migrationContext[$migration->name];
        if (!is_array($restoredContext) || !isset($restoredContext['context']) || !isset($restoredContext['step'] )) {
            throw new \Exception("Can not resume ".$this->getEntityName($migration)." '{$migration->name}': the stored context is invalid");
        }

        // update migration status
        $migration = $this->storageHandler->resumeMigration($migration);

        // clean up restored context - ideally it should be in the same db transaction as the line above
        $this->contextHandler->deleteContext($migration->name);

        // and go
        // note: we store the current step counting starting at 1, but use offset starting at 0, hence the -1 here
        $this->executeMigrationInner($migration, $migrationDefinition, $restoredContext['context'],
            $restoredContext['step'] - 1, $useTransaction);
    }
573476
protected function deleteIblockByCode($code)
    {
        $id = $this->getIblockIdByCode($code);

        $this->db->startTransaction();
        if (!CIBlock::Delete($id)) {
            $this->db->rollbackTransaction();
            throw new MigrationException('Ошибка при удалении инфоблока');
        }

        $this->db->commitTransaction();
    }
96525
public function add($migrationName) {
		$list = $this->getList(false);
		if(isset($list[$migrationName]))
			return;
		$list[$migrationName] = ['added'=>time()+microtime(true)];
		$this->writeMigrations($list);
	}
817864
public function run($migration_file, MigrationContext $context)
	{
		$closure = require $migration_file;

		if ( !is_callable($closure) ) {
			throw new \LogicException('The "' . basename($migration_file) . '" migration doesn\'t return a closure.');
		}

		call_user_func($closure, $context);
	}
741740
public function deleteMigrationContext($migrationName)
    {
        $this->createTableIfNeeded();
        $conn = $this->getConnection();
        $conn->delete($this->tableName, array('migration' => $migrationName));
    }
1045421
public function down()
    {
        $record = new MigrationRecord();
        if ($this->connection !== null) {
            $record->setConnection($this->connection);
        }
        $record->where('migration', $this->name)->delete();
    }
1162709
public function addMigration(string $path, Migration $migrations): void{
        $name = basename($path);
        $this->migrations[$name] = $migrations;
    }
249212
public function insert(Migration $migration)
    {
        $fileName = $this->_getFileName($migration);
        if (is_file($fileName)) {
            throw new \InvalidArgumentException(__METHOD__.": Migration file `{$migration->getName()}` exists");
        }

        file_put_contents($fileName, $migration->getSql());
    }