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 AddAnalyticsPodcastsByEpisode Creates analytics_episodes_by_episode 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
|
|
|
|
2023-06-13 18:05:02 +02:00
|
|
|
use App\Database\Migrations\BaseMigration;
|
2020-06-12 22:41:09 +02:00
|
|
|
|
2023-06-13 18:05:02 +02:00
|
|
|
class AddAnalyticsPodcastsByEpisode extends BaseMigration
|
2020-06-12 22:41:09 +02:00
|
|
|
{
|
2021-05-06 16:00:48 +02:00
|
|
|
public function up(): void
|
2020-06-12 22:41:09 +02:00
|
|
|
{
|
|
|
|
$this->forge->addField([
|
|
|
|
'podcast_id' => [
|
2023-06-12 16:47:38 +02:00
|
|
|
'type' => 'INT',
|
2020-06-12 22:41:09 +02:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
2020-10-06 17:39:27 +02:00
|
|
|
'date' => [
|
2020-10-29 16:45:19 +01:00
|
|
|
'type' => 'DATE',
|
2020-10-06 17:39:27 +02:00
|
|
|
],
|
2020-06-12 22:41:09 +02:00
|
|
|
'episode_id' => [
|
2023-06-12 16:47:38 +02:00
|
|
|
'type' => 'INT',
|
2020-06-12 22:41:09 +02:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
2020-10-06 17:39:27 +02:00
|
|
|
'age' => [
|
2023-06-12 16:47:38 +02:00
|
|
|
'type' => 'INT',
|
|
|
|
'comment' => 'Days since episode publication date',
|
2020-10-06 17:39:27 +02:00
|
|
|
'unsigned' => 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
|
|
|
],
|
|
|
|
]);
|
2020-10-07 13:38:15 +02:00
|
|
|
$this->forge->addPrimaryKey(['podcast_id', 'date', 'episode_id']);
|
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-02 19:20:02 +02:00
|
|
|
'`updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()',
|
2020-06-12 22:41:09 +02:00
|
|
|
);
|
2020-10-06 17:39:27 +02:00
|
|
|
$this->forge->createTable('analytics_podcasts_by_episode');
|
2020-06-12 22:41:09 +02:00
|
|
|
}
|
|
|
|
|
2021-05-06 16:00:48 +02:00
|
|
|
public function down(): void
|
2020-06-12 22:41:09 +02:00
|
|
|
{
|
2020-10-06 17:39:27 +02:00
|
|
|
$this->forge->dropTable('analytics_podcasts_by_episode');
|
2020-06-12 22:41:09 +02:00
|
|
|
}
|
|
|
|
}
|