Skip to content

Commit

Permalink
Limited short labels to 190 unicode characters maximum to simplify in…
Browse files Browse the repository at this point in the history
…dexation.
  • Loading branch information
Daniel Berthereau authored and Daniel Berthereau committed Feb 19, 2024
1 parent d6ad71b commit 3dcde0a
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 12 deletions.
12 changes: 6 additions & 6 deletions application/data/install/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SET FOREIGN_KEY_CHECKS = 0;
CREATE TABLE `api_key` (
`id` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
`owner_id` int NOT NULL,
`label` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`label` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`credential_hash` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL,
`last_ip` varbinary(16) DEFAULT NULL COMMENT '(DC2Type:ip_address)',
`last_accessed` datetime DEFAULT NULL,
Expand All @@ -14,7 +14,7 @@ CREATE TABLE `api_key` (
CREATE TABLE `asset` (
`id` int NOT NULL AUTO_INCREMENT,
`owner_id` int DEFAULT NULL,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`name` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`media_type` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`storage_id` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`extension` varchar(190) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
Expand Down Expand Up @@ -131,7 +131,7 @@ CREATE TABLE `property` (
`owner_id` int DEFAULT NULL,
`vocabulary_id` int NOT NULL,
`local_name` varchar(190) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`label` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`label` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`comment` longtext COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
UNIQUE KEY `UNIQ_8BF21CDEAD0E05F6623C14D5` (`vocabulary_id`,`local_name`),
Expand Down Expand Up @@ -168,7 +168,7 @@ CREATE TABLE `resource_class` (
`owner_id` int DEFAULT NULL,
`vocabulary_id` int NOT NULL,
`local_name` varchar(190) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`label` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`label` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`comment` longtext COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
UNIQUE KEY `UNIQ_C6F063ADAD0E05F6623C14D5` (`vocabulary_id`,`local_name`),
Expand Down Expand Up @@ -199,7 +199,7 @@ CREATE TABLE `resource_template_property` (
`id` int NOT NULL AUTO_INCREMENT,
`resource_template_id` int NOT NULL,
`property_id` int NOT NULL,
`alternate_label` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`alternate_label` varchar(190) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`alternate_comment` longtext COLLATE utf8mb4_unicode_ci,
`position` int DEFAULT NULL,
`data_type` longtext COLLATE utf8mb4_unicode_ci COMMENT '(DC2Type:json_array)',
Expand Down Expand Up @@ -379,7 +379,7 @@ CREATE TABLE `vocabulary` (
`owner_id` int DEFAULT NULL,
`namespace_uri` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`prefix` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`label` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`label` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`comment` longtext COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
UNIQUE KEY `UNIQ_9099C97B9B267FDF` (`namespace_uri`),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php declare(strict_types=1);

namespace Omeka\Db\Migrations;

use Doctrine\DBAL\Connection;
use Omeka\Db\Migration\MigrationInterface;

class LimitLabelsTo190Characters implements MigrationInterface
{
public function up(Connection $conn)
{
$sql = <<<'SQL'
ALTER TABLE `api_key`
CHANGE `label` `label` varchar(190) COLLATE 'utf8mb4_unicode_ci' NOT NULL AFTER `owner_id`;
ALTER TABLE `asset`
CHANGE `name` `name` varchar(190) COLLATE 'utf8mb4_unicode_ci' NOT NULL AFTER `owner_id`;
ALTER TABLE `property`
CHANGE `label` `label` varchar(190) COLLATE 'utf8mb4_unicode_ci' NOT NULL AFTER `local_name`;
ALTER TABLE `resource_class`
CHANGE `label` `label` varchar(190) COLLATE 'utf8mb4_unicode_ci' NOT NULL AFTER `local_name`;
ALTER TABLE `resource_template_property`
CHANGE `alternate_label` `alternate_label` varchar(190) COLLATE 'utf8mb4_unicode_ci' NULL AFTER `property_id`;
ALTER TABLE `vocabulary`
CHANGE `label` `label` varchar(190) COLLATE 'utf8mb4_unicode_ci' NOT NULL AFTER `prefix`;

SQL;
$conn->executeStatement($sql);
}
}
2 changes: 1 addition & 1 deletion application/src/Entity/ApiKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ApiKey extends AbstractEntity
protected $id;

/**
* @Column
* @Column(length=190)
*/
protected $label;

Expand Down
2 changes: 1 addition & 1 deletion application/src/Entity/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Asset extends AbstractEntity
protected $owner;

/**
* @Column
* @Column(length=190)
*/
protected $name;

Expand Down
2 changes: 1 addition & 1 deletion application/src/Entity/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Property extends AbstractEntity
protected $localName;

/**
* @Column
* @Column(length=190)
*/
protected $label;

Expand Down
2 changes: 1 addition & 1 deletion application/src/Entity/ResourceClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ResourceClass extends AbstractEntity
protected $localName;

/**
* @Column
* @Column(length=190)
*/
protected $label;

Expand Down
2 changes: 1 addition & 1 deletion application/src/Entity/ResourceTemplateProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ResourceTemplateProperty extends AbstractEntity
protected $property;

/**
* @Column(nullable=true)
* @Column(nullable=true, length=190)
*/
protected $alternateLabel;

Expand Down
2 changes: 1 addition & 1 deletion application/src/Entity/Vocabulary.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Vocabulary extends AbstractEntity
protected $prefix;

/**
* @Column
* @Column(length=190)
*/
protected $label;

Expand Down

0 comments on commit 3dcde0a

Please sign in to comment.