Get the Doctrine table difference for the given changes.

@param Blueprint $blueprint
@param AbstractSchemaManager $schema
@return TableDiff|bool
341321
protected function getChangedDiff( Blueprint $blueprint, SchemaManager $schema )
	{
		$table = $schema->listTableDetails( $this->getTablePrefix() . $blueprint->getTable() );

		return ( new Comparator )->diffTable( $table, $this->getTableWithColumnChanges( $blueprint, $table ) );
	}
694448
public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Connection $connection)
    {
        return RenameColumn::compile($this, $blueprint, $command, $connection);
    }
339077
public function diffChangeLogFromSchemaDiff(SchemaDiff $schemaDiff, $output = null)
    {
        $output = $this->sanitizeOutputParameter($output);

        $output->started($this->em);

        foreach ($schemaDiff->newNamespaces as $newNamespace) {
            $output->createSchema($newNamespace);
        }

        foreach ($schemaDiff->orphanedForeignKeys as $orphanedForeignKey) {
            $output->dropForeignKey($orphanedForeignKey, $orphanedForeignKey->getLocalTable());
        }

        foreach ($schemaDiff->changedSequences as $sequence) {
            $output->alterSequence($sequence);
        }

        foreach ($schemaDiff->removedSequences as $sequence) {
            $output->dropSequence($sequence);
        }

        foreach ($schemaDiff->newSequences as $sequence) {
            $output->createSequence($sequence);
        }

        foreach ($schemaDiff->newTables as $table) {
            $output->createTable($table);
            
            foreach ($table->getForeignKeys() as $foreignKey) {
                $output->createForeignKey($foreignKey, $table);
            }
        }

        foreach ($schemaDiff->removedTables as $table) {
            $output->dropTable($table);
        }

        foreach ($schemaDiff->changedTables as $tableDiff) {
            $output->alterTable($tableDiff);
        }

        $output->terminated();

        return $output->getResult();
    }
139031
public static function columns(Blueprint $table, $usesSoftDeletes = true)
    {
        self::addColumn($table, config('accountable.column_names.created_by'));
        self::addColumn($table, config('accountable.column_names.updated_by'));

        if ($usesSoftDeletes) {
            self::addColumn($table, config('accountable.column_names.deleted_by'));
        }
    }
196416
public function diffChangeLog($output = null, $metadata = null)
    {
        $output = $this->sanitizeOutputParameter($output);
        $metadata = $this->sanitizeMetadatas($metadata);

        $sm = $this->em->getConnection()->getSchemaManager();

        $fromSchema = $sm->createSchema();
        $this->removeLiquibaseTables($fromSchema);
        $toSchema = $this->getSchemaFromMetadata($metadata);

        $comparator = new Comparator();
        $schemaDiff = $comparator->compare($fromSchema, $toSchema);

        return $this->diffChangeLogFromSchemaDiff($schemaDiff, $output);
    }
546652
private function getTableDiffForAlterForeignKey($table)
    {
        if (! $table instanceof Table) {
            $tableDetails = $this->tryMethod('listTableDetails', $table);

            if ($tableDetails === false) {
                throw new DBALException(sprintf('Sqlite schema manager requires to modify foreign keys table definition "%s".', $table));
            }

            $table = $tableDetails;
        }

        $tableDiff            = new TableDiff($table->getName());
        $tableDiff->fromTable = $table;

        return $tableDiff;
    }
49391
public function compileAdd(Blueprint $blueprint, Fluent $command)
    {
        return sprintf('alter table %s add %s',
            $this->wrapTable($blueprint),
            implode(', ', $this->getColumns($blueprint))
        );
    }
810840
public function upgradeSchema(Schema $schema)
    {
        /* Add query log db table */

        try {
            $table = $schema->getTable('SystemDatabaseQueryLog');
        } catch (Exception $e) {
            $table = null;
        }
        if (!($table instanceof Table)) {
            $ql = $schema->createTable('SystemDatabaseQueryLog');
            $ql->addColumn('query', 'text');
            $ql->addColumn('params', 'text', ['notnull' => false]);
            $ql->addColumn('executionMS', 'string');
        }
    }
276094
protected function getSchemaUpAlterCommand(MigrationInput $input, $blueprintBody)
    {
        $stub = $this->getStubContent('migration-schema-up', $input->template);

        $this->replaceConnectionName($stub, $input->connectionName)
            ->replaceTableName($stub, $this->tableName)
            ->replaceOperationName($stub, 'table')
            ->replaceBlueprintBodyName($stub, $blueprintBody);

        return $stub;
    }
1131553
protected function verifyOuter(SchemaBuilder $builder, AbstractColumn $column)
    {
        foreach ($this->findTargets($builder) as $schema) {
            $outerTable = $builder->requestTable($schema->getTable(), $schema->getDatabase());

            if (!$outerTable->hasColumn($column->getName())) {
                //Column is missing
                throw new RelationSchemaException(
                    "Unable to build morphed relation, outer key '{$column->getName()}' "
                    . "is missing in '{$outerTable->getName()}'"
                );
            }

            if ($outerTable->column($column->getName())->phpType() != $column->phpType()) {
                //Inconsistent type
                throw new RelationSchemaException(
                    "Unable to build morphed relation, outer key '{$column->getName()}' "
                    . "has different type in '{$outerTable->getName()}'"
                );
            }
        }
    }
966884
public function delete(BlueprintInterface $blueprint)
    {
        Notification::where($this->getAttributes($blueprint))->update(['is_deleted' => true]);
    }
1286994
protected function targetTable(SchemaBuilder $builder): AbstractTable
    {
        $target = $this->getDefinition()->targetContext();
        if (empty($target)) {
            throw new RelationSchemaException(sprintf(
                "Unable to get target context '%s' in '%s'.'%s'",
                $this->getDefinition()->getTarget(),
                $this->getDefinition()->sourceContext()->getClass(),
                $this->getDefinition()->getName()
            ));
        }

        return $builder->requestTable($target->getTable(), $target->getDatabase());
    }
120797
protected function resolveForeignTable($table, Blueprint $blueprint)
    {
        $referenced = explode('.', $table);

        if (count($referenced) == 2) {
            return [
                'database' => current($referenced),
                'table' => next($referenced),
            ];
        }

        return [
            'database' => $blueprint->schema(),
            'table' => current($referenced),
        ];
    }
527853
public function compileForeign(Blueprint $blueprint, Fluent $command)
    {
        // We need to prepare several of the elements of the foreign key definition
        // before we can create the SQL, such as wrapping the tables and convert
        // an array of columns to comma-delimited strings for the SQL queries.
        $sql = sprintf('alter table %s add constraint %s ',
            $this->wrapTable($blueprint),
            $this->wrap($command->index)
        );

        // Once we have the initial portion of the SQL statement we will add on the
        // key name, table name, and referenced columns. These will complete the
        // main portion of the SQL statement and this SQL will almost be done.
        $sql .= sprintf('foreign key (%s) references %s (%s)',
            $this->columnize($command->columns),
            $this->wrapTable($command->on),
            $this->columnize((array) $command->references)
        );

        // Once we have the basic foreign key creation statement constructed we can
        // build out the syntax for what should happen on an update or delete of
        // the affected columns, which will get something like "cascade", etc.
        if (! is_null($command->onDelete)) {
            $sql .= " on delete {$command->onDelete}";
        }

        if (! is_null($command->onUpdate)) {
            $sql .= " on update {$command->onUpdate}";
        }

        return $sql;
    }
202897
protected function modifyAfter(Blueprint $blueprint, Fluent $column)
    {
        if (! is_null($column->after)) {
            return ' after '.$this->wrap($column->after);
        }
    }
1099505
public function compileRename(Blueprint $blueprint, Fluent $command)
    {
        $from = $this->wrapTable($blueprint);

        return "alter table {$from} rename to ".$this->wrapTable($command->to);
    }
1156292
public function compileCreate(Blueprint $blueprint, Fluent $command)
    {
        $columns = implode(', ', $this->getColumns($blueprint));

        $sql = 'create table '.$this->wrapTable($blueprint)." ($columns";

        // SQLite forces primary keys to be added when the table is initially created
        // so we will need to check for a primary key commands and add the columns
        // to the table's declaration here so they can be created on the tables.
        $sql .= (string) $this->addForeignKeys($blueprint);

        $sql .= (string) $this->addPrimaryKeys($blueprint);

        return $sql .= ')';
    }