codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.38k stars 1.9k forks source link

Bug: php spark make: migration--session, "timestamp" column type #4827

Closed tomomo closed 3 years ago

tomomo commented 3 years ago

Hello.

I noticed while reading #4807.

The documentation(https://codeigniter4.github.io/userguide/libraries/sessions.html?highlight=ci_sessions) specifies timestamp.

CREATE TABLE IF NOT EXISTS `ci_sessions` (
        `id` varchar(128) NOT NULL,
        `ip_address` varchar(45) NOT NULL,
        `timestamp` timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL,
        `data` blob NOT NULL,
        KEY `ci_sessions_timestamp` (`timestamp`)
);

But, the file created by php spark make: migration--session is an int.

class CreateCiSessionsTable extends Migration
{
    protected $DBGroup = 'default';

    public function up()
    {
        $this->forge->addField([
            'id'         => ['type' => 'VARCHAR', 'constraint' => 128, 'null' => false],
            'ip_address' => ['type' => 'VARCHAR', 'constraint' => 45, 'null' => false],
            'timestamp'  => ['type' => 'INT', 'unsigned' => true, 'null' => false, 'default' => 0],
            'data'       => ['type' => 'TEXT', 'null' => false, 'default' => ''],
        ]);
        $this->forge->addKey('id', true);
        $this->forge->addKey('timestamp');
        $this->forge->createTable('ci_sessions', true);
    }
  :

Context

michalsn commented 3 years ago

Resolved via #4877