2020-06-12 20:41:09 +00:00
|
|
|
|
<?php
|
2020-08-04 11:25:22 +00:00
|
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2020-06-12 20:41:09 +00:00
|
|
|
|
/**
|
2021-05-19 16:35:13 +00:00
|
|
|
|
* Class AddAnalyticsUnknownUseragents Creates analytics_unknown_useragents table in database
|
2021-04-02 17:20:02 +00:00
|
|
|
|
*
|
2022-02-19 16:06:11 +00:00
|
|
|
|
* @copyright 2020 Ad Aures
|
2020-06-12 20:41:09 +00:00
|
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
|
* @link https://castopod.org/
|
|
|
|
|
*/
|
2020-08-04 11:25:22 +00:00
|
|
|
|
|
2021-08-23 11:05:16 +00:00
|
|
|
|
namespace Modules\Analytics\Database\Migrations;
|
2020-06-12 20:41:09 +00:00
|
|
|
|
|
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
|
|
|
|
|
|
class AddAnalyticsUnknownUseragents extends Migration
|
|
|
|
|
{
|
2021-05-06 14:00:48 +00:00
|
|
|
|
public function up(): void
|
2020-06-12 20:41:09 +00:00
|
|
|
|
{
|
|
|
|
|
$this->forge->addField([
|
|
|
|
|
'id' => [
|
2020-10-29 15:45:19 +00:00
|
|
|
|
'type' => 'INT',
|
2020-06-12 20:41:09 +00:00
|
|
|
|
'unsigned' => true,
|
|
|
|
|
'auto_increment' => true,
|
|
|
|
|
],
|
|
|
|
|
'useragent' => [
|
|
|
|
|
'type' => 'VARCHAR',
|
2021-12-21 14:15:10 +00:00
|
|
|
|
'constraint' => 255,
|
2020-06-12 20:41:09 +00:00
|
|
|
|
'unique' => true,
|
|
|
|
|
],
|
|
|
|
|
'hits' => [
|
|
|
|
|
'type' => 'INT',
|
2020-10-29 15:45:19 +00:00
|
|
|
|
'unsigned' => true,
|
2020-06-12 20:41:09 +00:00
|
|
|
|
'default' => 1,
|
|
|
|
|
],
|
|
|
|
|
]);
|
2021-04-02 17:20:02 +00:00
|
|
|
|
|
|
|
|
|
$this->forge->addPrimaryKey('id');
|
2020-10-29 15:45:19 +00:00
|
|
|
|
// `created_at` and `updated_at` are created with SQL because Model class won’t be used for insertion (Procedure will be used instead)
|
2021-06-08 09:52:11 +00:00
|
|
|
|
$this->forge->addField('`created_at` timestamp NOT NULL DEFAULT current_timestamp()');
|
2020-06-12 20:41:09 +00:00
|
|
|
|
$this->forge->addField(
|
2021-04-14 15:58:40 +00:00
|
|
|
|
'`updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()',
|
2020-06-12 20:41:09 +00:00
|
|
|
|
);
|
|
|
|
|
$this->forge->createTable('analytics_unknown_useragents');
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-06 14:00:48 +00:00
|
|
|
|
public function down(): void
|
2020-06-12 20:41:09 +00:00
|
|
|
|
{
|
|
|
|
|
$this->forge->dropTable('analytics_unknown_useragents');
|
|
|
|
|
}
|
|
|
|
|
}
|