1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* _ __ __ _____ _____ ___ ____ _____ |
5
|
|
|
* | | / // // ___//_ _// || __||_ _| |
6
|
|
|
* | |/ // /(__ ) / / / /| || | | | |
7
|
|
|
* |___//_//____/ /_/ /_/ |_||_| |_| |
8
|
|
|
* @link https://vistart.me/ |
9
|
|
|
* @copyright Copyright (c) 2016 - 2017 vistart |
10
|
|
|
* @license https://vistart.me/license/ |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace rhosocial\organization\migrations; |
14
|
|
|
|
15
|
|
|
use rhosocial\organization\Organization; |
16
|
|
|
use rhosocial\user\migrations\Migration; |
17
|
|
|
use rhosocial\organization\OrganizationSetting; |
18
|
|
|
use rhosocial\user\User; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Class m170421_111104_createOrganizationSettingTable |
22
|
|
|
* @version 1.0 |
23
|
|
|
* @author vistart <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
class m170421_111104_createOrganizationSettingTable extends Migration |
26
|
|
|
{ |
27
|
|
|
public function up() |
28
|
|
|
{ |
29
|
|
|
if ($this->db->driverName == 'mysql') { |
30
|
|
|
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci |
31
|
|
|
$tableOptions = "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Organization Setting'"; |
32
|
|
|
$this->createTable(OrganizationSetting::tableName(), [ |
33
|
|
|
'guid' => $this->varbinary(16)->notNull()->comment('GUID'), |
34
|
|
|
'organization_guid' => $this->varbinary(16)->notNull()->comment('Organization GUID'), |
35
|
|
|
'operator_guid' => $this->varbinary(16)->comment('Operator GUID'), |
36
|
|
|
'item' => $this->varchar(255)->notNull()->defaultValue('')->comment('Item'), |
37
|
|
|
'value' => $this->varchar(255)->notNull()->defaultValue('')->comment('Item'), |
38
|
|
|
'created_at' => $this->dateTime()->notNull()->defaultValue('1970-01-01 00:00:00')->comment('Created At'), |
39
|
|
|
'updated_at' => $this->dateTime()->notNull()->defaultValue('1970-01-01 00:00:00')->comment('Updated At'), |
40
|
|
|
], $tableOptions); |
41
|
|
|
} |
42
|
|
|
$this->addPrimaryKey('organization_setting_guid_pk', OrganizationSetting::tableName(), 'guid'); |
43
|
|
|
$this->addForeignKey('organization_setting_organization_fk', OrganizationSetting::tableName(), 'organization_guid', Organization::tableName(), 'guid', 'CASCADE', 'CASCADE'); |
44
|
|
|
$this->addForeignKey('organization_setting_operator_fk', OrganizationSetting::tableName(), 'operator_guid', User::tableName(), 'guid', 'SET NULL', 'CASCADE'); |
45
|
|
|
$this->createIndex('organization_item_unique', OrganizationSetting::tableName(), ['organization_guid', 'item'], true); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function down() |
49
|
|
|
{ |
50
|
|
|
$this->dropTable(OrganizationSetting::tableName()); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/* |
54
|
|
|
// Use safeUp/safeDown to run migration code within a transaction |
55
|
|
|
public function safeUp() |
56
|
|
|
{ |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function safeDown() |
60
|
|
|
{ |
61
|
|
|
} |
62
|
|
|
*/ |
63
|
|
|
} |
64
|
|
|
|