Passed
Push — master ( d021a5...a13070 )
by Sam
03:47 queued 12s
created

m140630_080456_add_display_modes_table   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 12 2
A down() 0 3 1
1
<?php
2
3
class m140630_080456_add_display_modes_table extends CDbMigration
4
{
5
6
	public function up()
7
	{
8
		if (Yii::app()->db->schema->getTable('display_mode') !== null)
9
			return;
10
11
		// SQLite cannot add foreign keys after a table has been created so 
12
		// we'll have to do it in the definition
13
		$this->createTable('display_mode', array(
14
			'id'=>'pk',
15
			'user_id'=>'integer NOT NULL REFERENCES user(id) ON UPDATE CASCADE ON DELETE CASCADE',
16
			'context'=>'string NOT NULL',
17
			'mode'=>'string NOT NULL'
18
		));
19
	}
20
21
	public function down()
22
	{
23
		$this->dropTable('display_mode');
24
	}
25
26
}
27