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