2022-08-12 16:02:56 +00: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 16:05:02 +00:00
|
|
|
class AddNotifications extends BaseMigration
|
2022-08-12 16:02:56 +00:00
|
|
|
{
|
|
|
|
public function up(): void
|
|
|
|
{
|
|
|
|
$this->forge->addField([
|
|
|
|
'id' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2022-08-12 16:02:56 +00:00
|
|
|
'auto_increment' => true,
|
|
|
|
],
|
|
|
|
'actor_id' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'INT',
|
2022-08-12 16:02:56 +00:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'target_actor_id' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'INT',
|
2022-08-12 16:02:56 +00:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'post_id' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'BINARY',
|
2022-08-12 16:02:56 +00:00
|
|
|
'constraint' => 16,
|
2023-06-12 14:47:38 +00:00
|
|
|
'null' => true,
|
2022-08-12 16:02:56 +00:00
|
|
|
],
|
|
|
|
'activity_id' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'BINARY',
|
2022-08-12 16:02:56 +00:00
|
|
|
'constraint' => 16,
|
|
|
|
],
|
|
|
|
'type' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'ENUM',
|
2022-08-12 16:02:56 +00: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 11:50:23 +00:00
|
|
|
$this->forge->createTable($tablesPrefix . 'notifications');
|
2022-08-12 16:02:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function down(): void
|
|
|
|
{
|
2022-09-08 11:50:23 +00:00
|
|
|
$this->forge->dropTable(config('Fediverse')->tablesPrefix . 'notifications');
|
2022-08-12 16:02:56 +00:00
|
|
|
}
|
|
|
|
}
|