Cloudlog/application/migrations/116_add_timestamp_to_api.php
phl0 6929a061eb
Add a column to API keys to show last usage timestamp
Squashed commit of the following:

commit 83f12cc945fa717945062a841854498368d8cb10
Author: phl0
Date:   Tue Mar 21 12:24:53 2023 +0100

    Change default value to current date/time

commit e1cb72f3fc80f581ee30d927772efe0ffe155059
Author: phl0
Date:   Tue Mar 21 12:05:46 2023 +0100

    Add functions to update timestamps

commit d303f629a0b2d200e49da36766cf72ed37c3fe92
Merge: 01a9606a 7dd76923
Author: phl0
Date:   Tue Mar 21 11:13:21 2023 +0100

    Merge remote-tracking branch 'origin/dev' into apiKeyLastUsed

commit 01a9606afde6aad6be0f07f34f8584e540c50e8c
Author: phl0
Date:   Tue Mar 21 11:11:51 2023 +0100

    Reorder DB migration due to previous commits

commit ec5cd743b96dc1ed0f2740f7b2051f88549f4248
Author: phl0
Date:   Fri Mar 17 16:23:34 2023 +0100

    Basics for API key last used
2023-03-21 12:26:15 +01:00

21 行
442 B
PHP

<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Migration_add_timestamp_to_api extends CI_Migration
{
public function up()
{
$fields = array(
'last_used TIMESTAMP DEFAULT NOW() NOT NULL AFTER `last_change`',
);
if (!$this->db->field_exists('last_used', 'api')) {
$this->dbforge->add_column('api', $fields);
}
}
public function down()
{
$this->dbforge->drop_column('api', 'last_used');
}
}