forked from codeigniter4/CodeIgniter4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path004.php
More file actions
41 lines (36 loc) · 985 Bytes
/
004.php
File metadata and controls
41 lines (36 loc) · 985 Bytes
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
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateAuthorsTable extends Migration
{
public function up()
{
$this->forge->addField([
'id' => [
'type' => 'INTEGER',
'unsigned' => true,
'auto_increment' => true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => '255',
'null' => false,
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addPrimaryKey('id');
$this->forge->addUniqueKey('name');
$this->forge->createTable('authors');
}
public function down()
{
$this->forge->dropTable('authors');
}
}