onDelete example

$connection = KernelLifecycleManager::getConnection();

        $migration = new Migration1673420896RemoveUndefinedSalutation();
        $migration->update($connection);
        // test multiple execution         $migration->update($connection);

        foreach (self::ASSOCIATION_TABLES as $table) {
            $foreignKey = $this->getForeignKey($connection$table);

            static::assertInstanceOf(ForeignKeyConstraint::class$foreignKey);
            static::assertEquals('SET NULL', $foreignKey->onDelete());
        }
    }

    private function insertSalutation(Connection $connection, string $salutationKey): string
    {
        $id = Uuid::randomBytes();
        $connection->insert('salutation', [
            'id' => $id,
            'salutation_key' => $salutationKey,
            'created_at' => (new \DateTimeImmutable())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]);

        
continue;
                }

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

                if (!$deleteFlag instanceof Flag) {
                    continue;
                }

                if (\in_array($fk->onDelete(), self::DELETE_FLAG_TO_ACTION_MAPPING[$deleteFlag::class], true)) {
                    continue;
                }

                $associationViolations[$definition->getClass()][] = sprintf(
                    'ForeignKey "%s" on entity "%s" has wrong OnDelete behaviour, behaviour should be "%s",'
                    . 'because Association "%s" on entity "%s" defined flag "%s", got "%s" instead.',
                    $fk->getName(),
                    $reference->getEntityName(),
                    self::DELETE_FLAG_TO_ACTION_MAPPING[$deleteFlag::class][0],
                    $association->getPropertyName(),
                    $definition->getEntityName(),
                    
Home | Imprint | This part of the site doesn't use cookies.