2021-04-02 17:20:02 +00:00
|
|
|
<?php
|
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2021-04-02 17:20:02 +00:00
|
|
|
/**
|
2021-08-13 11:07:29 +00:00
|
|
|
* Class AddComments creates comments table in database
|
2021-04-02 17:20:02 +00:00
|
|
|
*
|
2021-08-13 11:07:29 +00:00
|
|
|
* @copyright 2020 Podlibre
|
2021-04-02 17:20:02 +00:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
2021-08-13 11:07:29 +00:00
|
|
|
namespace App\Database\Migrations;
|
2021-04-02 17:20:02 +00:00
|
|
|
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
|
2021-08-13 11:07:29 +00:00
|
|
|
class AddComments extends Migration
|
2021-04-02 17:20:02 +00:00
|
|
|
{
|
2021-05-06 14:00:48 +00:00
|
|
|
public function up(): void
|
2021-04-02 17:20:02 +00:00
|
|
|
{
|
|
|
|
$this->forge->addField([
|
|
|
|
'id' => [
|
|
|
|
'type' => 'BINARY',
|
|
|
|
'constraint' => 16,
|
|
|
|
],
|
|
|
|
'uri' => [
|
|
|
|
'type' => 'VARCHAR',
|
2021-08-13 11:07:29 +00:00
|
|
|
'constraint' => 255,
|
|
|
|
],
|
|
|
|
'episode_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2021-04-02 17:20:02 +00:00
|
|
|
],
|
|
|
|
'actor_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'in_reply_to_id' => [
|
|
|
|
'type' => 'BINARY',
|
|
|
|
'constraint' => 16,
|
|
|
|
'null' => true,
|
|
|
|
],
|
|
|
|
'message' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 500,
|
|
|
|
'null' => true,
|
|
|
|
],
|
|
|
|
'message_html' => [
|
|
|
|
'type' => 'VARCHAR',
|
|
|
|
'constraint' => 600,
|
|
|
|
'null' => true,
|
|
|
|
],
|
2021-08-13 11:07:29 +00:00
|
|
|
'likes_count' => [
|
2021-04-02 17:20:02 +00:00
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
],
|
2021-08-13 11:07:29 +00:00
|
|
|
'dislikes_count' => [
|
2021-04-02 17:20:02 +00:00
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'replies_count' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'created_at' => [
|
|
|
|
'type' => 'DATETIME',
|
|
|
|
],
|
2021-08-13 11:07:29 +00:00
|
|
|
'created_by' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
|
|
|
'null' => true,
|
|
|
|
],
|
2021-04-02 17:20:02 +00:00
|
|
|
]);
|
|
|
|
$this->forge->addPrimaryKey('id');
|
2021-08-13 11:07:29 +00:00
|
|
|
$this->forge->addForeignKey('episode_id', 'episodes', 'id', '', 'CASCADE');
|
2021-06-08 09:52:11 +00:00
|
|
|
$this->forge->addForeignKey('actor_id', 'activitypub_actors', 'id', '', 'CASCADE');
|
2021-08-13 11:07:29 +00:00
|
|
|
$this->forge->addForeignKey('created_by', 'users', 'id');
|
|
|
|
$this->forge->createTable('comments');
|
2021-04-02 17:20:02 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 14:00:48 +00:00
|
|
|
public function down(): void
|
2021-04-02 17:20:02 +00:00
|
|
|
{
|
2021-08-13 11:07:29 +00:00
|
|
|
$this->forge->dropTable('comments');
|
2021-04-02 17:20:02 +00:00
|
|
|
}
|
|
|
|
}
|