createTable($schema); $this->migrate($fromSchema, $schema); $this->addReport( Report::createSuccess( sprintf( 'Table "%s" successfully created', RdsValueCollectionRepository::TABLE_LIST_ITEMS ) ) ); } public function down(Schema $schema): void { $schema->dropTable(RdsValueCollectionRepository::TABLE_LIST_ITEMS); $this->addReport( Report::createSuccess( sprintf( 'Table "%s" successfully dropped', RdsValueCollectionRepository::TABLE_LIST_ITEMS ) ) ); } private function createTable(Schema $schema): void { $listItemsTable = $schema->createTable(RdsValueCollectionRepository::TABLE_LIST_ITEMS); $listItemsTable->addColumn( RdsValueCollectionRepository::FIELD_ITEM_ID, 'integer', ['autoincrement' => true] ); $listItemsTable->addColumn( RdsValueCollectionRepository::FIELD_ITEM_LABEL, 'string', ['length' => 255] ); $listItemsTable->addColumn( RdsValueCollectionRepository::FIELD_ITEM_URI, 'string', ['length' => 255] ); $listItemsTable->addColumn( RdsValueCollectionRepository::FIELD_ITEM_LIST_URI, 'string', ['length' => 255] ); $listItemsTable->setPrimaryKey([RdsValueCollectionRepository::FIELD_ITEM_ID]); $listItemsTable->addIndex([RdsValueCollectionRepository::FIELD_ITEM_LABEL]); $listItemsTable->addIndex([RdsValueCollectionRepository::FIELD_ITEM_LIST_URI]); $listItemsTable->addUniqueIndex([RdsValueCollectionRepository::FIELD_ITEM_URI]); } 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; } }