2022-08-12 18:02:56 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class AddNotifications Creates notifications table in database
|
|
|
|
*
|
|
|
|
* @copyright 2021 Ad Aures
|
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
|
2023-06-13 18:05:02 +02:00
|
|
|
class AddNotifications extends BaseMigration
|
2022-08-12 18:02:56 +02:00
|
|
|
{
|
|
|
|
public function up(): void
|
|
|
|
{
|
|
|
|
$this->forge->addField([
|
|
|
|
'id' => [
|
2023-06-12 16:47:38 +02:00
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2022-08-12 18:02:56 +02:00
|
|
|
'auto_increment' => true,
|
|
|
|
],
|
|
|
|
'actor_id' => [
|
2023-06-12 16:47:38 +02:00
|
|
|
'type' => 'INT',
|
2022-08-12 18:02:56 +02:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'target_actor_id' => [
|
2023-06-12 16:47:38 +02:00
|
|
|
'type' => 'INT',
|
2022-08-12 18:02:56 +02:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'post_id' => [
|
2023-06-12 16:47:38 +02:00
|
|
|
'type' => 'BINARY',
|
2022-08-12 18:02:56 +02:00
|
|
|
'constraint' => 16,
|
2023-06-12 16:47:38 +02:00
|
|
|
'null' => true,
|
2022-08-12 18:02:56 +02:00
|
|
|
],
|
|
|
|
'activity_id' => [
|
2023-06-12 16:47:38 +02:00
|
|
|
'type' => 'BINARY',
|
2022-08-12 18:02:56 +02:00
|
|
|
'constraint' => 16,
|
|
|
|
],
|
|
|
|
'type' => [
|
2023-06-12 16:47:38 +02:00
|
|
|
'type' => 'ENUM',
|
2022-08-12 18:02:56 +02:00
|
|
|
'constraint' => ['like', 'follow', 'share', 'reply'],
|
|
|
|
],
|
|
|
|
'read_at' => [
|
|
|
|
'type' => 'DATETIME',
|
|
|
|
'null' => true,
|
|
|
|
],
|
|
|
|
'created_at' => [
|
|
|
|
'type' => 'DATETIME',
|
|
|
|
],
|
|
|
|
'updated_at' => [
|
|
|
|
'type' => 'DATETIME',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
|
|
|
$tablesPrefix = config('Fediverse')
|
|
|
|
->tablesPrefix;
|
|
|
|
|
|
|
|
$this->forge->addPrimaryKey('id');
|
|
|
|
$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->addForeignKey('activity_id', $tablesPrefix . 'activities', 'id', '', 'CASCADE');
|
2022-09-08 13:50:23 +02:00
|
|
|
$this->forge->createTable($tablesPrefix . 'notifications');
|
2022-08-12 18:02:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function down(): void
|
|
|
|
{
|
2022-09-08 13:50:23 +02:00
|
|
|
$this->forge->dropTable(config('Fediverse')->tablesPrefix . 'notifications');
|
2022-08-12 18:02:56 +02:00
|
|
|
}
|
|
|
|
}
|