|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace dukt\analytics\migrations; |
|
4
|
|
|
|
|
5
|
|
|
use craft\db\Migration; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* The class name is the UTC timestamp in the format of mYYMMDD_HHMMSS_pluginHandle_migrationName |
|
9
|
|
|
*/ |
|
10
|
|
|
class m170613_000001_views extends Migration |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* Any migration code in here is wrapped inside of a transaction. |
|
14
|
|
|
* |
|
15
|
|
|
* @return bool |
|
16
|
|
|
*/ |
|
17
|
|
|
public function safeUp() |
|
18
|
|
|
{ |
|
19
|
|
|
$this->createTable( |
|
20
|
|
|
'{{%analytics_views}}', |
|
21
|
|
|
[ |
|
22
|
|
|
'id' => $this->primaryKey(), |
|
23
|
|
|
'name' => $this->string()->notNull(), |
|
24
|
|
|
'gaAccountId' => $this->string()->notNull(), |
|
25
|
|
|
'gaAccountName' => $this->string()->notNull(), |
|
26
|
|
|
'gaPropertyId' => $this->string()->notNull(), |
|
27
|
|
|
'gaPropertyName' => $this->string()->notNull(), |
|
28
|
|
|
'gaViewId' => $this->string()->notNull(), |
|
29
|
|
|
'gaViewName' => $this->string()->notNull(), |
|
30
|
|
|
'gaViewCurrency' => $this->string()->notNull(), |
|
31
|
|
|
|
|
32
|
|
|
'dateCreated' => $this->dateTime()->notNull(), |
|
33
|
|
|
'dateUpdated' => $this->dateTime()->notNull(), |
|
34
|
|
|
'uid' => $this->uid() |
|
35
|
|
|
] |
|
36
|
|
|
); |
|
37
|
|
|
|
|
38
|
|
|
$this->createTable( |
|
39
|
|
|
'{{%analytics_site_views}}', |
|
40
|
|
|
[ |
|
41
|
|
|
'id' => $this->primaryKey(), |
|
42
|
|
|
'siteId' => $this->integer()->notNull(), |
|
43
|
|
|
'viewId' => $this->integer(), |
|
44
|
|
|
|
|
45
|
|
|
'dateCreated' => $this->dateTime()->notNull(), |
|
46
|
|
|
'dateUpdated' => $this->dateTime()->notNull(), |
|
47
|
|
|
'uid' => $this->uid() |
|
48
|
|
|
] |
|
49
|
|
|
); |
|
50
|
|
|
|
|
51
|
|
|
$this->createIndex(null, '{{%analytics_site_views}}', 'siteId,viewId', true); |
|
52
|
|
|
$this->addForeignKey($this->db->getForeignKeyName('{{%analytics_site_views}}', 'siteId'), '{{%analytics_site_views}}', 'siteId', '{{%sites}}', 'id', 'CASCADE', null); |
|
|
|
|
|
|
53
|
|
|
$this->addForeignKey($this->db->getForeignKeyName('{{%analytics_site_views}}', 'viewId'), '{{%analytics_site_views}}', 'viewId', '{{%analytics_views}}', 'id', 'CASCADE', null); |
|
54
|
|
|
|
|
55
|
|
|
return true; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @inheritdoc |
|
60
|
|
|
*/ |
|
61
|
|
|
public function safeDown() |
|
62
|
|
|
{ |
|
63
|
|
|
echo "m170613_000001_views cannot be reverted.\n"; |
|
64
|
|
|
|
|
65
|
|
|
return false; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.