*/ class LtiResultAliasStorage_v1 { const TABLE_NAME = 'lti_result_identifiers'; const DELIVERY_EXECUTION_ID = 'delivery_execution_id'; const RESULT_ID = 'result_id'; /** * Create table in database * @param \common_persistence_SqlPersistence $persistence */ public static function apply(\common_persistence_SqlPersistence $persistence) { /** @var AbstractSchemaManager $schemaManager */ $schemaManager = $persistence->getDriver()->getSchemaManager(); /** @var Schema $schema */ $schema = $schemaManager->createSchema(); $fromSchema = clone $schema; try { $table = $schema->createTable(self::TABLE_NAME); $table->addOption('engine', 'MyISAM'); $table->addColumn(self::DELIVERY_EXECUTION_ID, "string", ["notnull" => true, 'comment' => 'Delivery Execution Identifier']); $table->addColumn(self::RESULT_ID, "string", ["notnull" => true, 'comment' => 'Results Identifier']); $table->setPrimaryKey([self::DELIVERY_EXECUTION_ID]); $table->addUniqueIndex([self::RESULT_ID], 'IDX_' . self::RESULT_ID . '_UNIQUE'); } catch (SchemaException $e) { \common_Logger::i('Database Schema of LtiResultIdStorage service already up to date.'); } $queries = $persistence->getPlatForm()->getMigrateSchemaSql($fromSchema, $schema); foreach ($queries as $query) { $persistence->exec($query); } } }