51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
use CodeIgniter\Database\RawSql;
|
|
|
|
class CreateUserTable extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
$this->forge->addField([
|
|
'id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 5,
|
|
'unsigned' => true,
|
|
'auto_increment' => true,
|
|
],
|
|
'name' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => '150',
|
|
'unique' => true,
|
|
],
|
|
'email' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => '150',
|
|
'unique' => true,
|
|
],
|
|
'password' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => '150',
|
|
],
|
|
'created_at' => [
|
|
'type' => 'TIMESTAMP',
|
|
'default' => new RawSql('CURRENT_TIMESTAMP'),
|
|
],
|
|
|
|
]);
|
|
|
|
$this->forge->addPrimaryKey('id');
|
|
$this->forge->addUniqueKey('name');
|
|
$this->forge->addUniqueKey('email');
|
|
$this->forge->createTable('users');
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$this->forge->dropTable('users');
|
|
}
|
|
}
|