mirror of
https://github.com/JGH0/Todo-App-Backend.git
synced 2026-06-03 13:28:47 +02:00
60 lines
1.5 KiB
PHP
60 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class CreateUsersTable extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
$this->forge->addField([
|
|
'id' => [
|
|
'type' => 'CHAR',
|
|
'constraint' => 36,
|
|
'null' => false,
|
|
],
|
|
'email' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 255,
|
|
'null' => false,
|
|
],
|
|
'password_hash' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 255,
|
|
'null' => false,
|
|
],
|
|
'name' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 255,
|
|
'null' => true,
|
|
],
|
|
'avatar_url' => [
|
|
'type' => 'TEXT',
|
|
'null' => true,
|
|
],
|
|
'settings' => [
|
|
'type' => 'JSON',
|
|
'null' => true,
|
|
'default' => '{}',
|
|
],
|
|
'created_at' => [
|
|
'type' => 'DATETIME',
|
|
'null' => true,
|
|
],
|
|
'updated_at' => [
|
|
'type' => 'DATETIME',
|
|
'null' => true,
|
|
],
|
|
]);
|
|
$this->forge->addKey('id', true);
|
|
$this->forge->addUniqueKey('email');
|
|
$this->forge->createTable('users');
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$this->forge->dropTable('users');
|
|
}
|
|
}
|