m140630_080456_add_display_modes_table::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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