<NME> m171015_194127_add_timezone.php
<BEF> ADDFILE
<MSG> Add Guam Time

Signed-off-by: AIZAWA Hina <07c779d48779c322a7c5324109202f9012f7aebf@bouhime.com>

<DFF> @@ -0,0 +1,62 @@
+<?php
+/**
+ * @copyright Copyright (C) 2015-2017 AIZAWA Hina
+ * @license https://github.com/fetus-hina/stat.ink/blob/master/LICENSE MIT
+ * @author AIZAWA Hina <hina@bouhime.com>
+ */
+
+use app\components\db\Migration;
+use yii\db\Query;
+
+class m171015_194127_add_timezone extends Migration
+{
+    public function safeUp()
+    {
+        $regionNA = (new Query())
+            ->select(['id'])
+            ->from('region')
+            ->where(['key' => 'na'])
+            ->scalar();
+
+        $groupOceania = (new Query())
+            ->select(['id'])
+            ->from('timezone_group')
+            ->where(['name' => 'Australia/Oceania'])
+            ->scalar();
+
+        $countryUS = (new Query())
+            ->select(['id'])
+            ->from('country')
+            ->where(['key' => 'us'])
+            ->scalar();
+
+        $this->insert('timezone', [
+            'identifier' => 'Pacific/Guam',
+            'name' => 'Guam Time',
+            'order' => 32,
+            'region_id' => $regionNA,
+            'group_id' => $groupOceania,
+        ]);
+        $tz = (new Query())
+            ->select(['id'])
+            ->from('timezone')
+            ->where(['identifier' => 'Pacific/Guam'])
+            ->scalar();
+        $this->insert('timezone_country', [
+            'timezone_id' => $tz,
+            'country_id' => $countryUS,
+        ]);
+    }
+
+    public function safeDown()
+    {
+        $tz = (new Query())
+            ->select(['id'])
+            ->from('timezone')
+            ->where(['identifier' => 'Pacific/Guam'])
+            ->scalar();
+
+        $this->delete('timezone_country', ['timezone_id' => $tz]);
+        $this->delete('timezone', ['id' => $tz]);
+    }
+}

{'addition_count': 62, 'commit_subject': 'Add Guam Time', 'deletion_count': 0, 'file_extension': '.php', 'lang': 'php', 'license': 'mit', 'repo_name': 'fetus-hina/stat.ink'}