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 AddFavourites Creates favourites 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 AddFavourites 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([
|
|
|
|
'actor_id' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'INT',
|
2021-04-02 17:20:02 +00:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
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,
|
|
|
|
],
|
|
|
|
]);
|
2021-08-27 10:58:22 +00:00
|
|
|
|
|
|
|
$tablesPrefix = config('Fediverse')
|
|
|
|
->tablesPrefix;
|
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
$this->forge->addField('`created_at` timestamp NOT NULL DEFAULT current_timestamp()');
|
2021-08-13 11:07:29 +00:00
|
|
|
$this->forge->addPrimaryKey(['actor_id', 'post_id']);
|
2021-08-27 10:58:22 +00:00
|
|
|
$this->forge->addForeignKey('actor_id', $tablesPrefix . 'actors', 'id', '', 'CASCADE');
|
|
|
|
$this->forge->addForeignKey('post_id', $tablesPrefix . 'posts', 'id', '', 'CASCADE');
|
|
|
|
$this->forge->createTable($tablesPrefix . 'favourites');
|
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 . 'favourites');
|
2021-04-02 17:20:02 +00:00
|
|
|
}
|
|
|
|
}
|