2021-08-13 16:07:45 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class AddLikes Creates likes table in database
|
|
|
|
*
|
2022-02-19 16:06:11 +00:00
|
|
|
* @copyright 2021 Ad Aures
|
2021-08-13 16:07:45 +00:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
2021-08-23 11:05:16 +00:00
|
|
|
namespace App\Database\Migrations;
|
2021-08-13 16:07:45 +00:00
|
|
|
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
|
|
|
|
class AddLikes extends Migration
|
|
|
|
{
|
|
|
|
public function up(): void
|
|
|
|
{
|
|
|
|
$this->forge->addField([
|
|
|
|
'actor_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'comment_id' => [
|
|
|
|
'type' => 'BINARY',
|
|
|
|
'constraint' => 16,
|
|
|
|
],
|
|
|
|
]);
|
2021-08-27 10:58:22 +00:00
|
|
|
|
|
|
|
$fediverseTablesPrefix = config('Fediverse')
|
|
|
|
->tablesPrefix;
|
|
|
|
|
2021-08-13 16:07:45 +00:00
|
|
|
$this->forge->addField('`created_at` timestamp NOT NULL DEFAULT current_timestamp()');
|
|
|
|
$this->forge->addPrimaryKey(['actor_id', 'comment_id']);
|
2021-08-27 10:58:22 +00:00
|
|
|
$this->forge->addForeignKey('actor_id', $fediverseTablesPrefix . 'actors', 'id', '', 'CASCADE');
|
2021-08-13 16:07:45 +00:00
|
|
|
$this->forge->addForeignKey('comment_id', 'episode_comments', 'id', '', 'CASCADE');
|
|
|
|
$this->forge->createTable('likes');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function down(): void
|
|
|
|
{
|
|
|
|
$this->forge->dropTable('likes');
|
|
|
|
}
|
|
|
|
}
|