hasTable($this->concatPrefix(SmartLinkHit::TABLE_NAME)); } protected function up(): void { $schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema(); $table = $this->concatPrefix(SmartLinkHit::TABLE_NAME); $this->addSql(<<addSql($this->generateAlterTableForeignKeyStatement( SmartLinkHit::TABLE_NAME, ['smart_link_id'], $this->resolveLinksTableName($schema), ['id'], 'ON DELETE CASCADE' )); } /** * The links table under the name it has right now: Version_0_5_0 renames utm_smart_links to * smart_links, and an update from 0.2.0 runs this migration before the rename. */ private function resolveLinksTableName(Schema $schema): string { return $schema->hasTable($this->concatPrefix('smart_links')) ? 'smart_links' : 'utm_smart_links'; } }