m140630_080456_add_display_modes_table   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 9
c 1
b 1
f 0
dl 0
loc 21
rs 10
wmc 3

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