I have some nextcloud code in php how to create a table. I want to convert it to mysql. Sounds like an easy task, but the docu and documentation is not clear to me.
This line:
$table->setPrimaryKey(['objecttype', 'objectid', 'systemtagid'], 'som_pk');
seems to use an array and a new column as index. I do not know where som_pk comes from and how to write it in mysql orders. Same goes for index.
Can someone give ma a hint?
if (!$schema->hasTable('systemtag_object_mapping')) {
$table = $schema->createTable('systemtag_object_mapping');
$table->addColumn('objectid', 'string', [
'notnull' => true,
'length' => 64,
'default' => '',
]);
$table->addColumn('objecttype', 'string', [
'notnull' => true,
'length' => 64,
'default' => '',
]);
$table->addColumn('systemtagid', 'integer', [
'notnull' => true,
'length' => 4,
'default' => 0,
'unsigned' => true,
]);
$table->setPrimaryKey(['objecttype', 'objectid', 'systemtagid'], 'som_pk');
// $table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping');
$table->addIndex(['systemtagid', 'objecttype'], 'systag_by_tagid');
}
>
This is the mysql code I created from it. I am unsure how to create the index and can not find anything about it in php tutorials. Can someone jump in and tell me how to create the index properly?
CREATE table nextcloud.oc_systemtag_object_mapping (
objectid VARCHAR(64) NOT NULL ,
objecttype VARCHAR(64) NOT NULL,
systemtagid INT,
PRIMARY KEY(objecttype, objectid, systemtagid)
);
CREATE INDEX ??? ON nextcloud.oc_systemtag_object_mapping(???)