ViewCreationMigration   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 9 2
A down() 0 4 1
1
<?php
2
3
use Phinx\Migration\AbstractMigration;
4
5
class ViewCreationMigration extends AbstractMigration
6
{
7
	/**
8
	 * Change Method.
9
	 *
10
	 * More information on this method is available here:
11
	 * http://docs.phinx.org/en/latest/migrations.html#the-change-method
12
	 *
13
	 * Uncomment this method if you would like to use it.
14
	 *
15
	public function change()
16
	{
17
	}
18
	*/
19
	
20
	/**
21
	 * Migrate Up.
22
	 */
23
	public function up()
24
	{
25
		if ( ! $this->hasTable('todo_task_view'))
26
		{
27
			$this->execute("CREATE VIEW todo_task_view AS
28
				SELECT todo_item.id, todo_item.user_id, todo_item.category_id, todo_item.title, todo_item.due, todo_item.modified, todo_item.created, todo_category.title AS category, todo_priority.value AS priority, todo_status.value AS status, todo_status.id AS status_id FROM (((todo_item LEFT JOIN todo_category ON ((todo_category.id = todo_item.category_id))) LEFT JOIN todo_priority ON ((todo_priority.id = todo_item.priority))) LEFT JOIN todo_status ON ((todo_status.id = todo_item.status))) ORDER BY todo_item.due, todo_item.priority DESC, todo_item.created;
29
				");
30
		}
31
	}
32
33
	/**
34
	 * Migrate Down.
35
	 */
36
	public function down()
37
	{
38
		$this->execute('DROP VIEW todo_task_view');
39
	}
40
}