Skip to content

Commit

Permalink
Limited short fields to 190 unicode characters to simplify indexation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Berthereau authored and Daniel Berthereau committed Feb 19, 2024
1 parent 89a3864 commit d6ad71b
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 28 deletions.
28 changes: 14 additions & 14 deletions application/data/install/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ CREATE TABLE `asset` (
`id` int NOT NULL AUTO_INCREMENT,
`owner_id` int DEFAULT NULL,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`media_type` varchar(255) 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(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`extension` varchar(190) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`alt_text` longtext COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
UNIQUE KEY `UNIQ_2AF5A5C5CC5DB90` (`storage_id`),
Expand Down Expand Up @@ -71,9 +71,9 @@ CREATE TABLE `item_site` (
CREATE TABLE `job` (
`id` int NOT NULL AUTO_INCREMENT,
`owner_id` int DEFAULT NULL,
`pid` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`class` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`pid` varchar(190) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` varchar(190) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`class` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`args` longtext COLLATE utf8mb4_unicode_ci COMMENT '(DC2Type:json_array)',
`log` longtext COLLATE utf8mb4_unicode_ci,
`started` datetime NOT NULL,
Expand All @@ -85,13 +85,13 @@ CREATE TABLE `job` (
CREATE TABLE `media` (
`id` int NOT NULL,
`item_id` int NOT NULL,
`ingester` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`renderer` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`ingester` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`renderer` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`data` longtext COLLATE utf8mb4_unicode_ci COMMENT '(DC2Type:json_array)',
`source` longtext COLLATE utf8mb4_unicode_ci,
`media_type` varchar(190) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`storage_id` varchar(190) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`extension` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`extension` varchar(190) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`sha256` char(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`size` bigint DEFAULT NULL,
`has_original` tinyint(1) NOT NULL,
Expand All @@ -114,7 +114,7 @@ CREATE TABLE `migration` (
CREATE TABLE `module` (
`id` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`is_active` tinyint(1) NOT NULL,
`version` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`version` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE `password_creation` (
Expand Down Expand Up @@ -150,7 +150,7 @@ CREATE TABLE `resource` (
`is_public` tinyint(1) NOT NULL,
`created` datetime NOT NULL,
`modified` datetime DEFAULT NULL,
`resource_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`resource_type` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `IDX_BC91F4167E3C61F9` (`owner_id`),
KEY `IDX_BC91F416448CC1BD` (`resource_class_id`),
Expand Down Expand Up @@ -205,7 +205,7 @@ CREATE TABLE `resource_template_property` (
`data_type` longtext COLLATE utf8mb4_unicode_ci COMMENT '(DC2Type:json_array)',
`is_required` tinyint(1) NOT NULL,
`is_private` tinyint(1) NOT NULL,
`default_lang` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`default_lang` varchar(190) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UNIQ_4689E2F116131EA549213EC` (`resource_template_id`,`property_id`),
KEY `IDX_4689E2F116131EA` (`resource_template_id`),
Expand Down Expand Up @@ -283,7 +283,7 @@ CREATE TABLE `site_page` (
`slug` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`title` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`is_public` tinyint(1) NOT NULL,
`layout` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`layout` varchar(190) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`layout_data` longtext COLLATE utf8mb4_unicode_ci COMMENT '(DC2Type:json)',
`created` datetime NOT NULL,
`modified` datetime DEFAULT NULL,
Expand Down Expand Up @@ -351,8 +351,8 @@ CREATE TABLE `value` (
`property_id` int NOT NULL,
`value_resource_id` int DEFAULT NULL,
`value_annotation_id` int DEFAULT NULL,
`type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`lang` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`type` varchar(190) COLLATE utf8mb4_unicode_ci NOT NULL,
`lang` varchar(190) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`value` longtext COLLATE utf8mb4_unicode_ci,
`uri` longtext COLLATE utf8mb4_unicode_ci,
`is_public` tinyint(1) NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php declare(strict_types=1);

namespace Omeka\Db\Migrations;

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

class LimitFieldsTo190Characters implements MigrationInterface
{
public function up(Connection $conn)
{
$sql = <<<'SQL'
ALTER TABLE `asset`
CHANGE `media_type` `media_type` varchar(190) COLLATE 'utf8mb4_unicode_ci' NOT NULL AFTER `name`,
CHANGE `extension` `extension` varchar(190) COLLATE 'utf8mb4_unicode_ci' NULL AFTER `storage_id`;
ALTER TABLE `job`
CHANGE `pid` `pid` varchar(190) COLLATE 'utf8mb4_unicode_ci' NULL AFTER `owner_id`,
CHANGE `status` `status` varchar(190) COLLATE 'utf8mb4_unicode_ci' NULL AFTER `pid`,
CHANGE `class` `class` varchar(190) COLLATE 'utf8mb4_unicode_ci' NOT NULL AFTER `status`;
ALTER TABLE `media`
CHANGE `ingester` `ingester` varchar(190) COLLATE 'utf8mb4_unicode_ci' NOT NULL AFTER `item_id`,
CHANGE `renderer` `renderer` varchar(190) COLLATE 'utf8mb4_unicode_ci' NOT NULL AFTER `ingester`,
CHANGE `media_type` `media_type` varchar(190) COLLATE 'utf8mb4_unicode_ci' NULL AFTER `source`,
CHANGE `extension` `extension` varchar(190) COLLATE 'utf8mb4_unicode_ci' NULL AFTER `storage_id`;
ALTER TABLE `module`
CHANGE `version` `version` varchar(190) COLLATE 'utf8mb4_unicode_ci' NOT NULL AFTER `is_active`;
ALTER TABLE `resource`
CHANGE `resource_type` `resource_type` varchar(190) COLLATE 'utf8mb4_unicode_ci' NOT NULL AFTER `modified`;
ALTER TABLE `resource_template_property`
CHANGE `default_lang` `default_lang` varchar(190) COLLATE 'utf8mb4_unicode_ci' NULL AFTER `is_private`;
ALTER TABLE `site_page`
CHANGE `layout` `layout` varchar(190) COLLATE 'utf8mb4_unicode_ci' NULL AFTER `modified`;
ALTER TABLE `value`
CHANGE `type` `type` varchar(190) COLLATE 'utf8mb4_unicode_ci' NOT NULL AFTER `value_resource_id`,
CHANGE `lang` `lang` varchar(190) COLLATE 'utf8mb4_unicode_ci' NULL AFTER `type`;

SQL;
$conn->executeStatement($sql);
}
}
4 changes: 2 additions & 2 deletions application/src/Entity/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Asset extends AbstractEntity
protected $name;

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

Expand All @@ -35,7 +35,7 @@ class Asset extends AbstractEntity
protected $storageId;

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

Expand Down
6 changes: 3 additions & 3 deletions application/src/Entity/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ class Job extends AbstractEntity
protected $id;

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

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

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

Expand Down
6 changes: 3 additions & 3 deletions application/src/Entity/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class Media extends Resource
protected $id;

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

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

Expand All @@ -55,7 +55,7 @@ class Media extends Resource
protected $storageId;

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion application/src/Entity/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @Entity
* @InheritanceType("JOINED")
* @DiscriminatorColumn(name="resource_type", type="string")
* @DiscriminatorColumn(name="resource_type", type="string", length=190)
* @Table(
* indexes={
* @Index(
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 @@ -63,7 +63,7 @@ class ResourceTemplateProperty extends AbstractEntity
protected $isPrivate = false;

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

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

/**
* @Column(type="string", nullable=true)
* @Column(type="string", nullable=true, length=190)
*/
protected $layout;

Expand Down
4 changes: 2 additions & 2 deletions application/src/Entity/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class Value extends AbstractEntity
protected $property;

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

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

Expand Down

0 comments on commit d6ad71b

Please sign in to comment.