2021-04-02 19:20:02 +02:00
|
|
|
<?php
|
|
|
|
|
2021-06-08 11:52:11 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2021-04-02 19:20:02 +02:00
|
|
|
/**
|
2021-08-27 12:58:22 +02:00
|
|
|
* Class AddFollowers Creates followers table in database
|
2021-04-02 19:20:02 +02:00
|
|
|
*
|
2022-02-19 17:06:11 +01:00
|
|
|
* @copyright 2021 Ad Aures
|
2021-04-02 19:20:02 +02:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
2021-08-23 13:05:16 +02:00
|
|
|
namespace Modules\Fediverse\Database\Migrations;
|
2021-04-02 19:20:02 +02:00
|
|
|
|
2023-06-13 18:05:02 +02:00
|
|
|
use App\Database\Migrations\BaseMigration;
|
2021-04-02 19:20:02 +02:00
|
|
|
|
2023-06-13 18:05:02 +02:00
|
|
|
class AddFollowers extends BaseMigration
|
2021-04-02 19:20:02 +02:00
|
|
|
{
|
2021-05-06 16:00:48 +02:00
|
|
|
public function up(): void
|
2021-04-02 19:20:02 +02:00
|
|
|
{
|
|
|
|
$this->forge->addField([
|
|
|
|
'actor_id' => [
|
2023-06-12 16:47:38 +02:00
|
|
|
'type' => 'INT',
|
2021-04-02 19:20:02 +02:00
|
|
|
'unsigned' => true,
|
2023-06-12 16:47:38 +02:00
|
|
|
'comment' => 'Actor that is following',
|
2021-04-02 19:20:02 +02:00
|
|
|
],
|
|
|
|
'target_actor_id' => [
|
2023-06-12 16:47:38 +02:00
|
|
|
'type' => 'INT',
|
2021-04-02 19:20:02 +02:00
|
|
|
'unsigned' => true,
|
2023-06-12 16:47:38 +02:00
|
|
|
'comment' => 'Actor that is followed',
|
2021-04-02 19:20:02 +02:00
|
|
|
],
|
|
|
|
]);
|
2021-08-27 12:58:22 +02:00
|
|
|
|
|
|
|
$tablesPrefix = config('Fediverse')
|
|
|
|
->tablesPrefix;
|
|
|
|
|
2021-06-08 11:52:11 +02:00
|
|
|
$this->forge->addField('`created_at` timestamp NOT NULL DEFAULT current_timestamp()');
|
2021-04-02 19:20:02 +02:00
|
|
|
$this->forge->addPrimaryKey(['actor_id', 'target_actor_id']);
|
2021-08-27 12:58:22 +02:00
|
|
|
$this->forge->addForeignKey('actor_id', $tablesPrefix . 'actors', 'id', '', 'CASCADE');
|
|
|
|
$this->forge->addForeignKey('target_actor_id', $tablesPrefix . 'actors', 'id', '', 'CASCADE');
|
|
|
|
$this->forge->createTable($tablesPrefix . 'follows');
|
2021-04-02 19:20:02 +02:00
|
|
|
}
|
|
|
|
|
2021-05-06 16:00:48 +02:00
|
|
|
public function down(): void
|
2021-04-02 19:20:02 +02:00
|
|
|
{
|
2021-08-27 12:58:22 +02:00
|
|
|
$this->forge->dropTable(config('Fediverse')->tablesPrefix . 'follows');
|
2021-04-02 19:20:02 +02:00
|
|
|
}
|
|
|
|
}
|