listTableForeignKeys example

throw new \RuntimeException(
                'Tables with multi column primary keys not supported. Maybe this migration did already run.'
            );
        }
        $pkName = current($pk->getColumns());

        return sprintf(self::MODIFY_PRIMARY_KEY_IN_MAIN, $tableName$newColumnName$defaultValue$pkName$pkName$newColumnName);
    }

    private function findForeignKeyDefinition(array $keyStructure): ForeignKeyConstraint
    {
        $fks = $this->schemaManager->listTableForeignKeys($keyStructure['TABLE_NAME']);
        $fk = null;

        foreach ($fks as $fk) {
            if ($this->isEqualForeignKey($fk$keyStructure['REFERENCED_TABLE_NAME']$keyStructure['REFERENCED_COLUMN_NAME'])) {
                break;
            }
        }

        if ($fk === null) {
            throw new \LogicException('Unable to find a foreign key that was previously selected');
        }

        
$connection->insert('salutation', [
            'id' => $id,
            'salutation_key' => $salutationKey,
            'created_at' => (new \DateTimeImmutable())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]);

        return $id;
    }

    private function getForeignKey(Connection $connection, string $relationTable): ?ForeignKeyConstraint
    {
        $foreignKeys = $connection->createSchemaManager()->listTableForeignKeys($relationTable);

        foreach ($foreignKeys as $foreignKey) {
            if (!$foreignKey instanceof ForeignKeyConstraint) {
                continue;
            }

            if ($foreignKey->getForeignTableName() === 'salutation' && $foreignKey->getLocalColumns() === ['salutation_id']) {
                return $foreignKey;
            }
        }

        

    private function validateForeignKeyOnDeleteBehaviour(EntityDefinition $definition, OneToManyAssociationField|ManyToManyAssociationField $association, EntityDefinition $reference, array $associationViolations): array
    {
        $manager = $this->connection->createSchemaManager();

        if ($association->getFlag(CascadeDelete::class)
            || $association->getFlag(RestrictDelete::class)
            || $association->getFlag(SetNullOnDelete::class)) {
            $fks = $manager->listTableForeignKeys($reference->getEntityName());

            foreach ($fks as $fk) {
                if ($fk->getForeignTableName() !== $definition->getEntityName() || !\in_array($association->getReferenceField()$fk->getLocalColumns(), true)) {
                    continue;
                }

                $deleteFlag = $association->getFlag(CascadeDelete::class)
                    ?? $association->getFlag(RestrictDelete::class)
                    ?? $association->getFlag(SetNullOnDelete::class);

                if (!$deleteFlag instanceof Flag) {
                    
$schemaManager = $connection->createSchemaManager();

        $tableName = '_dpkc_main';

        $playbookGenerator = new MakeVersionableMigrationHelper($connection);

        $hydratedData = $playbookGenerator->getRelationData($tableName, 'id');
        $playbook = $playbookGenerator->createSql($hydratedData$tableName, 'mission_id', Uuid::randomHex());

        foreach ($this->getExpectationsBefore() as $tableName => $expectation) {
            $indexes = $schemaManager->listTableIndexes($tableName);
            $foreignKeys = $schemaManager->listTableForeignKeys($tableName);
            $columns = $schemaManager->listTableColumns($tableName);

            static::assertCount($expectation['indexes']$indexesprint_r($indexes, true) . ' index on ' . $tableName);
            static::assertCount($expectation['foreignKeys']$foreignKeysprint_r($foreignKeys, true) . ' foreignKey on ' . $tableName);
            static::assertCount($expectation['columns']$columnsprint_r($columns, true) . ' columns on ' . $tableName);
        }

        foreach ($playbook as $query) {
            $connection->executeStatement($query);
        }

        
Home | Imprint | This part of the site doesn't use cookies.