castopod/app/Database/Migrations/2020-06-08-210000_add_analytics_unknown_useragents.php
Yassine Doghri ed6e953010 refactor: add php_codesniffer to define castopod's coding style based on psr-1
- add .editorconfig file
- format all files to comply with castopod's coding style
- switch parsedown dependency with commonmark library to better follow commonmark spec for markdown
- add prettier command to format all project files at once

closes #16
2020-10-15 14:41:22 +00:00

56 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Class AddAnalyticsUnknownUseragents
* Creates analytics_unknown_useragents table in database
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class AddAnalyticsUnknownUseragents extends Migration
{
public function up()
{
$this->forge->addField([
'id' => [
'type' => 'BIGINT',
'constraint' => 20,
'unsigned' => true,
'auto_increment' => true,
'comment' => 'The line ID',
],
'useragent' => [
'type' => 'VARCHAR',
'constraint' => 191,
'unique' => true,
'comment' => 'The unknown user-agent.',
],
'hits' => [
'type' => 'INT',
'constraint' => 10,
'default' => 1,
'comment' => 'Number of hits.',
],
]);
$this->forge->addKey('id', true);
// `created_at` and `updated_at` are created with SQL because Model class wont be used for insertion (Stored Procedure will be used instead)
$this->forge->addField(
'`created_at` timestamp NOT NULL DEFAULT current_timestamp()'
);
$this->forge->addField(
'`updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()'
);
$this->forge->createTable('analytics_unknown_useragents');
}
public function down()
{
$this->forge->dropTable('analytics_unknown_useragents');
}
}