createTable($schema); $this->migrate($fromSchema, $schema); $this->addReport( Report::createSuccess( sprintf( 'Table "%s" successfully created', RdsValueCollectionRepository::TABLE_LIST_ITEMS_DEPENDENCIES ) ) ); } public function down(Schema $schema): void { $schema->dropTable(RdsValueCollectionRepository::TABLE_LIST_ITEMS_DEPENDENCIES); $this->addReport( Report::createSuccess( sprintf( 'Table "%s" successfully dropped', RdsValueCollectionRepository::TABLE_LIST_ITEMS_DEPENDENCIES ) ) ); } private function createTable(Schema $schema): void { $listItemsDependenciesTable = $schema->createTable( RdsValueCollectionRepository::TABLE_LIST_ITEMS_DEPENDENCIES ); $listItemsDependenciesTable->addColumn( RdsValueCollectionRepository::FIELD_LIST_ITEM_ID, 'integer' ); $listItemsDependenciesTable->addColumn( RdsValueCollectionRepository::FIELD_LIST_ITEM_FIELD, 'string', ['length' => 255] ); $listItemsDependenciesTable->addColumn( RdsValueCollectionRepository::FIELD_LIST_ITEM_VALUE, 'string', ['length' => 255] ); $listItemsDependenciesTable->addIndex([RdsValueCollectionRepository::FIELD_LIST_ITEM_ID]); $listItemsDependenciesTable->addIndex([RdsValueCollectionRepository::FIELD_LIST_ITEM_FIELD]); $listItemsDependenciesTable->addIndex([RdsValueCollectionRepository::FIELD_LIST_ITEM_VALUE]); $listItemsDependenciesTable->addForeignKeyConstraint( RdsValueCollectionRepository::TABLE_LIST_ITEMS, [RdsValueCollectionRepository::FIELD_LIST_ITEM_ID], [RdsValueCollectionRepository::FIELD_ITEM_ID] ); } private function migrate(Schema $fromSchema, Schema $schema): void { $queries = $this->getPersistence()->getPlatForm()->getMigrateSchemaSql($fromSchema, $schema); foreach ($queries as $query) { $this->getPersistence()->exec($query); } } private function getPersistence(): SqlPersistence { if (!isset($this->persistence)) { $persistenceManager = $this->getServiceLocator()->get(PersistenceManager::SERVICE_ID); $this->persistence = $persistenceManager->getPersistenceById('default'); } return $this->persistence; } }