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-05-19 16:35:13 +00:00
|
|
|
* Class AddCreatedByToNotes Adds created_by field to activitypub_notes table in database
|
2021-04-02 17:20:02 +00:00
|
|
|
*
|
|
|
|
* @copyright 2020 Podlibre
|
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
|
|
|
|
class AddCreatedByToNotes extends Migration
|
|
|
|
{
|
2021-05-06 14:00:48 +00:00
|
|
|
public function up(): void
|
2021-04-02 17:20:02 +00:00
|
|
|
{
|
|
|
|
$prefix = $this->db->getPrefix();
|
|
|
|
|
2021-05-19 16:35:13 +00:00
|
|
|
$createQuery = <<<CODE_SAMPLE
|
2021-05-06 14:00:48 +00:00
|
|
|
ALTER TABLE {$prefix}activitypub_notes
|
2021-04-02 17:20:02 +00:00
|
|
|
ADD COLUMN `created_by` INT UNSIGNED AFTER `episode_id`,
|
2021-05-06 14:00:48 +00:00
|
|
|
ADD FOREIGN KEY {$prefix}activitypub_notes_created_by_foreign(created_by) REFERENCES {$prefix}users(id) ON DELETE CASCADE;
|
2021-05-19 16:35:13 +00:00
|
|
|
CODE_SAMPLE;
|
2021-04-02 17:20:02 +00:00
|
|
|
$this->db->query($createQuery);
|
|
|
|
}
|
|
|
|
|
2021-05-06 14:00:48 +00:00
|
|
|
public function down(): void
|
2021-04-02 17:20:02 +00:00
|
|
|
{
|
2021-06-08 09:52:11 +00:00
|
|
|
$this->forge->dropForeignKey('activitypub_notes', 'activitypub_notes_created_by_foreign');
|
2021-04-02 17:20:02 +00:00
|
|
|
$this->forge->dropColumn('activitypub_notes', 'created_by');
|
|
|
|
}
|
|
|
|
}
|