diff --git a/CHANGELOG.md b/CHANGELOG.md index a1647b3..8b5d2cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,14 @@ # Changelog +## [1.3.6] - 2018-06-18 +### Changed +- DB fallback: Schema - changed `url` field from `varchar(255) to `text` to allow longer urls +- DB fallback: Schema - Added `urlHash` + + ## [1.3.5] - 2018-05-26 ### Changed -- DB fallback: Changed `tags` field form `varchar(255) to `text` to allow more tags +- DB fallback: Schema - changed `tags` field from `varchar(255) to `text` to allow more tags ## [1.3.4] - 2018-05-08 ### Changed diff --git a/composer.json b/composer.json index b721507..6670dc5 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "ostark/upper", "description": "A cache plugin for Craft - supporting multiple Edge Caches", "type": "craft-plugin", - "version": "1.3.5", + "version": "1.3.6", "keywords": [ "craft", "cms", @@ -36,7 +36,6 @@ "extra": { "name": "Upper", "handle": "upper", - "schemaVersion": "0.1.0", "hasCpSettings": false, "hasCpSection": false, "changelogUrl": "https://raw.githubusercontent.com/ostark/upper/master/CHANGELOG.md" diff --git a/src/Plugin.php b/src/Plugin.php index 46bb919..6432746 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -37,7 +37,7 @@ class Plugin extends BasePlugin // Header const INFO_HEADER_NAME = 'X-UPPER-CACHE'; - public $schemaVersion = '1.0.0'; + public $schemaVersion = '1.0.1'; /** diff --git a/src/migrations/Install.php b/src/migrations/Install.php index 66b2b9d..5b4045c 100644 --- a/src/migrations/Install.php +++ b/src/migrations/Install.php @@ -20,8 +20,7 @@ public function safeUp() $this->createTable(Plugin::CACHE_TABLE, [ 'uid' => $this->string(40)->notNull()->unique(), - 'urlHash' => $this->string(32)->notNull(), - 'url' => $this->text()->notNull(), + 'url' => $this->string(255)->notNull(), 'headers' => $this->text()->defaultValue(null), 'tags' => $this->text()->notNull(), 'siteId' => $this->integer(), @@ -29,7 +28,7 @@ public function safeUp() 'dateUpdated' => $this->dateTime()->null() ]); - $this->createIndex('url_idx', Plugin::CACHE_TABLE, 'urlHash', true); + $this->createIndex('url_idx', Plugin::CACHE_TABLE, 'url', true); $this->execute("ALTER TABLE " . Plugin::CACHE_TABLE . " ADD FULLTEXT INDEX tags_fulltext (tags ASC)"); } @@ -39,7 +38,6 @@ public function safeUp() $this->createTable(Plugin::CACHE_TABLE, [ 'uid' => $this->string(40)->notNull()->unique(), - 'urlHash' => $this->string(32)->notNull(), 'url' => $this->string(255)->notNull(), 'headers' => $this->text()->defaultValue(null), 'tags' => 'varchar[]', @@ -49,7 +47,7 @@ public function safeUp() 'PRIMARY KEY(uid)', ]); - $this->createIndex('url_idx', Plugin::CACHE_TABLE, 'urlHash', true); + $this->createIndex('url_idx', Plugin::CACHE_TABLE, 'url', true); $this->execute("CREATE INDEX tags_array ON " . Plugin::CACHE_TABLE . " USING GIN(tags)"); } diff --git a/src/migrations/m180618_120307_url_index.php b/src/migrations/m180618_120307_url_index.php new file mode 100644 index 0000000..71867e1 --- /dev/null +++ b/src/migrations/m180618_120307_url_index.php @@ -0,0 +1,43 @@ + Truncate table: " . Plugin::CACHE_TABLE . PHP_EOL; + $this->truncateTable(Plugin::CACHE_TABLE); + + echo " > Drop index: url_idx" . PHP_EOL; + $this->dropIndex('url_idx', Plugin::CACHE_TABLE); + + echo " > Alter column: 'url' - string to text " . PHP_EOL; + $this->alterColumn(Plugin::CACHE_TABLE, 'url', $this->text()); + + echo " > Add column: 'urlHash'" . PHP_EOL; + $this->addColumn(Plugin::CACHE_TABLE, 'urlHash', $this->string(32)->notNull()->after('url')); + + echo " > Create index: urlhash_idx" . PHP_EOL; + + $this->createIndex('urlhash_idx', Plugin::CACHE_TABLE, 'urlHash', true); + } + + /** + * @inheritdoc + */ + public function safeDown() + { + echo "m180618_120307_url_index cannot be reverted.\n"; + return false; + } +}