Skip to content

Commit

Permalink
Merge pull request #6 from carlcs/master
Browse files Browse the repository at this point in the history
Fix Craft 3 migration
  • Loading branch information
mmikkel authored Feb 28, 2019
2 parents f45e2b6 + e82ee7f commit 769f1ce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.1.1.1 - 2019-02-28
### Added
- Fixed an error that occurred when updating to Incognito 1.1.1 on Craft 3.0.x

## 1.1.1 - 2019-02-28
### Added
- Adds Craft 3 migration. Thanks @carcls!
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mmikkel/incognito-field",
"description": "PlainText drop-in replacement that can be set to disabled, hidden or readonly.",
"type": "craft-plugin",
"version": "1.1.1",
"version": "1.1.1.1",
"keywords": [
"craft",
"cms",
Expand Down
7 changes: 3 additions & 4 deletions src/migrations/m190226_225231_craft3.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use craft\db\Migration;
use craft\db\Query;
use craft\db\Table;
use craft\helpers\ArrayHelper;
use craft\helpers\Db;
use craft\helpers\Json;
Expand All @@ -22,7 +21,7 @@ class m190226_225231_craft3 extends Migration
public function safeUp()
{
$this->migratePlainTextSettings();
$this->update(Table::FIELDS, ['type' => IncognitoFieldType::class], ['type' => 'IncognitoField']);
$this->update('{{%fields}}', ['type' => IncognitoFieldType::class], ['type' => 'IncognitoField']);
}

/**
Expand All @@ -33,7 +32,7 @@ public function migratePlainTextSettings()
{
$fields = (new Query())
->select(['id', 'settings'])
->from([Table::FIELDS])
->from(['{{%fields}}'])
->where(['type' => 'IncognitoField'])
->all($this->db);

Expand All @@ -56,7 +55,7 @@ public function migratePlainTextSettings()
$settings['columnType'] = Schema::TYPE_TEXT;
}

$this->update(Table::FIELDS, [
$this->update('{{%fields}}', [
'settings' => Json::encode($settings)
], ['id' => $field['id']]);
}
Expand Down

0 comments on commit 769f1ce

Please sign in to comment.