/
20160428212500_Create_test_tables.php
58 lines (50 loc) · 1.85 KB
/
20160428212500_Create_test_tables.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php namespace Tests\Support\Database\Migrations;
class Migration_Create_test_tables extends \CodeIgniter\Database\Migration
{
public function up()
{
// User Table
$this->forge->addField([
'id' => ['type' => 'INTEGER', 'constraint' => 3, 'auto_increment' => true],
'name' => ['type' => 'VARCHAR', 'constraint' => 80,],
'email' => ['type' => 'VARCHAR', 'constraint' => 100],
'country' => ['type' => 'VARCHAR', 'constraint' => 40,],
'deleted' => ['type' => 'TINYINT', 'constraint' => 1, 'default' => '0'],
]);
$this->forge->addKey('id', true);
$this->forge->createTable('user', true);
// Job Table
$this->forge->addField([
'id' => ['type' => 'INTEGER', 'constraint' => 3, 'auto_increment' => true],
'name' => ['type' => 'VARCHAR', 'constraint' => 40],
'description' => ['type' => 'TEXT'],
'created_at' => ['type' => 'DATETIME', 'null' => true]
]);
$this->forge->addKey('id', true);
$this->forge->createTable('job', true);
// Misc Table
$this->forge->addField([
'id' => ['type' => 'INTEGER', 'constraint' => 3, 'auto_increment' => true ],
'key' => ['type' => 'VARCHAR', 'constraint' => 40],
'value' => ['type' => 'TEXT'],
]);
$this->forge->addKey('id', true);
$this->forge->createTable('misc', true);
// Empty Table
$this->forge->addField([
'id' => ['type' => 'INTEGER', 'constraint' => 3, 'auto_increment' => true],
'name' => ['type' => 'VARCHAR', 'constraint' => 40,],
]);
$this->forge->addKey('id', true);
$this->forge->createTable('empty', true);
}
//--------------------------------------------------------------------
public function down()
{
$this->forge->dropTable('user');
$this->forge->dropTable('job');
$this->forge->dropTable('misc');
$this->forge->dropTable('empty');
}
//--------------------------------------------------------------------
}