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-27 10:58:22 +00:00
|
|
|
* Class AddActivities Creates activities table in database
|
2021-04-02 17:20:02 +00:00
|
|
|
*
|
2022-02-19 16:06:11 +00:00
|
|
|
* @copyright 2021 Ad Aures
|
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-23 11:05:16 +00:00
|
|
|
namespace Modules\Fediverse\Database\Migrations;
|
2021-04-02 17:20:02 +00:00
|
|
|
|
2023-06-13 16:05:02 +00:00
|
|
|
use App\Database\Migrations\BaseMigration;
|
2021-04-02 17:20:02 +00:00
|
|
|
|
2023-06-13 16:05:02 +00:00
|
|
|
class AddActivities extends BaseMigration
|
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' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'BINARY',
|
2021-04-02 17:20:02 +00:00
|
|
|
'constraint' => 16,
|
|
|
|
],
|
|
|
|
'actor_id' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'INT',
|
2021-04-02 17:20:02 +00:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'target_actor_id' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'INT',
|
2021-04-02 17:20:02 +00:00
|
|
|
'unsigned' => true,
|
2023-06-12 14:47:38 +00:00
|
|
|
'null' => true,
|
2021-04-02 17:20:02 +00:00
|
|
|
],
|
2021-08-13 11:07:29 +00:00
|
|
|
'post_id' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'BINARY',
|
2021-04-02 17:20:02 +00:00
|
|
|
'constraint' => 16,
|
2023-06-12 14:47:38 +00:00
|
|
|
'null' => true,
|
2021-04-02 17:20:02 +00:00
|
|
|
],
|
|
|
|
'type' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'VARCHAR',
|
2021-04-02 17:20:02 +00:00
|
|
|
'constraint' => 100,
|
|
|
|
],
|
|
|
|
'payload' => [
|
|
|
|
'type' => 'JSON',
|
|
|
|
],
|
2021-12-14 16:41:10 +00:00
|
|
|
'status' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'ENUM',
|
2021-04-02 17:20:02 +00:00
|
|
|
'constraint' => ['queued', 'delivered'],
|
2023-06-12 14:47:38 +00:00
|
|
|
'null' => true,
|
2021-04-02 17:20:02 +00:00
|
|
|
],
|
|
|
|
'scheduled_at' => [
|
|
|
|
'type' => 'DATETIME',
|
|
|
|
'null' => true,
|
|
|
|
],
|
|
|
|
'created_at' => [
|
|
|
|
'type' => 'DATETIME',
|
|
|
|
],
|
|
|
|
]);
|
2021-08-27 10:58:22 +00:00
|
|
|
|
|
|
|
$tablesPrefix = config('Fediverse')
|
|
|
|
->tablesPrefix;
|
|
|
|
|
2021-04-02 17:20:02 +00:00
|
|
|
$this->forge->addPrimaryKey('id');
|
2021-08-27 10:58:22 +00:00
|
|
|
$this->forge->addForeignKey('actor_id', $tablesPrefix . 'actors', 'id', '', 'CASCADE');
|
|
|
|
$this->forge->addForeignKey('target_actor_id', $tablesPrefix . 'actors', 'id', '', 'CASCADE');
|
|
|
|
$this->forge->addForeignKey('post_id', $tablesPrefix . 'posts', 'id', '', 'CASCADE');
|
|
|
|
$this->forge->createTable($tablesPrefix . 'activities');
|
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-27 10:58:22 +00:00
|
|
|
$this->forge->dropTable(config('Fediverse')->tablesPrefix . 'activities');
|
2021-04-02 17:20:02 +00:00
|
|
|
}
|
|
|
|
}
|