Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • adaures/castopod
  • mkljczk/castopod-host
  • spaetz/castopod-host
  • PatrykMis/castopod
  • jonas/castopod
  • ajeremias/castopod
  • misuzu/castopod
  • KrzysztofDomanczyk/castopod
  • Behel/castopod
  • nebulon/castopod
  • ewen/castopod
  • NeoluxConsulting/castopod
  • nateritter/castopod-og
  • prcutler/castopod
14 results
Show changes
Showing
with 581 additions and 236 deletions
......@@ -5,39 +5,40 @@ declare(strict_types=1);
/**
* Class AddPodcasts Creates podcasts table in database
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
class AddPodcasts extends Migration
class AddPodcasts extends BaseMigration
{
#[Override]
public function up(): void
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'unsigned' => true,
'type' => 'INT',
'unsigned' => true,
'auto_increment' => true,
],
'guid' => [
'type' => 'CHAR',
'type' => 'CHAR',
'constraint' => 36,
],
'actor_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'handle' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 32,
],
'title' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 128,
],
'description_markdown' => [
......@@ -47,50 +48,50 @@ class AddPodcasts extends Migration
'type' => 'TEXT',
],
'cover_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'banner_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
'null' => true,
'null' => true,
],
'language_code' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 2,
],
'category_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
'default' => 0,
'default' => 0,
],
'parental_advisory' => [
'type' => 'ENUM',
'type' => 'ENUM',
'constraint' => ['clean', 'explicit'],
'null' => true,
'null' => true,
],
'owner_name' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 128,
],
'owner_email' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 255,
],
'publisher' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 128,
'null' => true,
'null' => true,
],
'type' => [
'type' => 'ENUM',
'type' => 'ENUM',
'constraint' => ['episodic', 'serial'],
'default' => 'episodic',
'default' => 'episodic',
],
'copyright' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 128,
'null' => true,
'null' => true,
],
'episode_description_footer_markdown' => [
'type' => 'TEXT',
......@@ -101,91 +102,94 @@ class AddPodcasts extends Migration
'null' => true,
],
'is_blocked' => [
'type' => 'TINYINT',
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
'default' => 0,
],
'is_completed' => [
'type' => 'TINYINT',
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
'default' => 0,
],
'is_locked' => [
'type' => 'TINYINT',
'type' => 'TINYINT',
'constraint' => 1,
'default' => 1,
'default' => 1,
],
'imported_feed_url' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 512,
'comment' =>
'The RSS feed URL if this podcast was imported, NULL otherwise.',
'null' => true,
'comment' => 'The RSS feed URL if this podcast was imported, NULL otherwise.',
'null' => true,
],
'new_feed_url' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 512,
'comment' =>
'The RSS new feed URL if this podcast is moving out, NULL otherwise.',
'null' => true,
'comment' => 'The RSS new feed URL if this podcast is moving out, NULL otherwise.',
'null' => true,
],
'payment_pointer' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 128,
'comment' => 'Wallet address for Web Monetization payments',
'null' => true,
'comment' => 'Wallet address for Web Monetization payments',
'null' => true,
],
'location_name' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 128,
'null' => true,
'null' => true,
],
'location_geo' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 32,
'null' => true,
'null' => true,
],
'location_osm' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 12,
'null' => true,
'null' => true,
],
'custom_rss' => [
'type' => 'JSON',
'null' => true,
],
'partner_id' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 32,
'null' => true,
'null' => true,
],
'partner_link_url' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 512,
'null' => true,
'null' => true,
],
'partner_image_url' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 512,
'null' => true,
'null' => true,
],
'is_premium_by_default' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
],
'created_by' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'updated_by' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'created_at' => [
'published_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'created_at' => [
'type' => 'DATETIME',
],
'deleted_at' => [
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
......@@ -194,7 +198,7 @@ class AddPodcasts extends Migration
$this->forge->addUniqueKey('handle');
$this->forge->addUniqueKey('guid');
$this->forge->addUniqueKey('actor_id');
$this->forge->addForeignKey('actor_id', config('Fediverse')->tablesPrefix . 'actors', 'id', '', 'CASCADE');
$this->forge->addForeignKey('actor_id', 'fediverse_actors', 'id', '', 'CASCADE');
$this->forge->addForeignKey('cover_id', 'media', 'id');
$this->forge->addForeignKey('banner_id', 'media', 'id', '', 'SET NULL');
$this->forge->addForeignKey('category_id', 'categories', 'id');
......@@ -204,6 +208,7 @@ class AddPodcasts extends Migration
$this->forge->createTable('podcasts');
}
#[Override]
public function down(): void
{
$this->forge->dropTable('podcasts');
......
......@@ -5,43 +5,44 @@ declare(strict_types=1);
/**
* Class AddEpisodes Creates episodes table in database
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
class AddEpisodes extends Migration
class AddEpisodes extends BaseMigration
{
#[Override]
public function up(): void
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'unsigned' => true,
'type' => 'INT',
'unsigned' => true,
'auto_increment' => true,
],
'podcast_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'guid' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 255,
],
'title' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 128,
],
'slug' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 128,
],
'audio_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'description_markdown' => [
......@@ -51,90 +52,95 @@ class AddEpisodes extends Migration
'type' => 'TEXT',
],
'cover_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
'null' => true,
'null' => true,
],
'transcript_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
'null' => true,
'null' => true,
],
'transcript_remote_url' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 512,
'null' => true,
'null' => true,
],
'chapters_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
'null' => true,
'null' => true,
],
'chapters_remote_url' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 512,
'null' => true,
'null' => true,
],
'parental_advisory' => [
'type' => 'ENUM',
'type' => 'ENUM',
'constraint' => ['clean', 'explicit'],
'null' => true,
'null' => true,
],
'number' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
'null' => true,
'null' => true,
],
'season_number' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
'null' => true,
'null' => true,
],
'type' => [
'type' => 'ENUM',
'type' => 'ENUM',
'constraint' => ['trailer', 'full', 'bonus'],
'default' => 'full',
'default' => 'full',
],
'is_blocked' => [
'type' => 'TINYINT',
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
'default' => 0,
],
'location_name' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 128,
'null' => true,
'null' => true,
],
'location_geo' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 32,
'null' => true,
'null' => true,
],
'location_osm' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 12,
'null' => true,
'null' => true,
],
'custom_rss' => [
'type' => 'JSON',
'null' => true,
],
'posts_count' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
'default' => 0,
'default' => 0,
],
'comments_count' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
'default' => 0,
'default' => 0,
],
'is_premium' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
],
'created_by' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'updated_by' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'published_at' => [
......@@ -147,10 +153,6 @@ class AddEpisodes extends Migration
'updated_at' => [
'type' => 'DATETIME',
],
'deleted_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addPrimaryKey('id');
$this->forge->addUniqueKey(['podcast_id', 'slug']);
......@@ -162,8 +164,17 @@ class AddEpisodes extends Migration
$this->forge->addForeignKey('created_by', 'users', 'id');
$this->forge->addForeignKey('updated_by', 'users', 'id');
$this->forge->createTable('episodes');
// Add Full-Text Search index on title and description_markdown
$prefix = $this->db->getPrefix();
$createQuery = <<<SQL
ALTER TABLE {$prefix}episodes
ADD FULLTEXT title (title, description_markdown);
SQL;
$this->db->query($createQuery);
}
#[Override]
public function down(): void
{
$this->forge->dropTable('episodes');
......
......@@ -5,48 +5,52 @@ declare(strict_types=1);
/**
* Class AddPlatforms Creates platforms table in database
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
class AddPlatforms extends Migration
class AddPlatforms extends BaseMigration
{
#[Override]
public function up(): void
{
$this->forge->addField([
'slug' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 32,
],
'type' => [
'type' => 'ENUM',
'type' => 'ENUM',
'constraint' => ['podcasting', 'social', 'funding'],
],
'label' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 32,
],
'home_url' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 255,
],
'submit_url' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 512,
'null' => true,
'null' => true,
],
]);
$this->forge->addField('`created_at` timestamp NOT NULL DEFAULT NOW()');
$this->forge->addField('`updated_at` timestamp NOT NULL DEFAULT NOW() ON UPDATE NOW()');
$this->forge->addField('`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP()');
$this->forge->addField(
'`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP()',
);
$this->forge->addPrimaryKey('slug');
$this->forge->createTable('platforms');
}
#[Override]
public function down(): void
{
$this->forge->dropTable('platforms');
......
......@@ -5,46 +5,47 @@ declare(strict_types=1);
/**
* Class AddAddPodcastsPlatforms Creates podcasts_platforms table in database
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
class AddPodcastsPlatforms extends Migration
class AddPodcastsPlatforms extends BaseMigration
{
#[Override]
public function up(): void
{
$this->forge->addField([
'podcast_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'platform_slug' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 32,
],
'link_url' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 512,
],
'account_id' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 128,
'null' => true,
'null' => true,
],
'is_visible' => [
'type' => 'TINYINT',
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
'default' => 0,
],
'is_on_embed' => [
'type' => 'TINYINT',
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
'default' => 0,
],
]);
......@@ -54,6 +55,7 @@ class AddPodcastsPlatforms extends Migration
$this->forge->createTable('podcasts_platforms');
}
#[Override]
public function down(): void
{
$this->forge->dropTable('podcasts_platforms');
......
......@@ -5,77 +5,76 @@ declare(strict_types=1);
/**
* Class AddEpisodeComments creates episode_comments table in database
*
* @copyright 2021 Podlibre
* @copyright 2021 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
class AddEpisodeComments extends Migration
class AddEpisodeComments extends BaseMigration
{
#[Override]
public function up(): void
{
$this->forge->addField([
'id' => [
'type' => 'BINARY',
'type' => 'BINARY',
'constraint' => 16,
],
'uri' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 255,
],
'episode_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'actor_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'in_reply_to_id' => [
'type' => 'BINARY',
'type' => 'BINARY',
'constraint' => 16,
'null' => true,
'null' => true,
],
'message' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 5000,
],
'message_html' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 6000,
],
'likes_count' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'replies_count' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'created_at' => [
'type' => 'DATETIME',
],
'created_by' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
'null' => true,
'null' => true,
],
]);
$fediverseTablesPrefix = config('Fediverse')
->tablesPrefix;
$this->forge->addPrimaryKey('id');
$this->forge->addForeignKey('episode_id', 'episodes', 'id', '', 'CASCADE');
$this->forge->addForeignKey('actor_id', $fediverseTablesPrefix . 'actors', 'id', '', 'CASCADE');
$this->forge->addForeignKey('actor_id', 'fediverse_actors', 'id', '', 'CASCADE');
$this->forge->addForeignKey('created_by', 'users', 'id');
$this->forge->createTable('episode_comments');
}
#[Override]
public function down(): void
{
$this->forge->dropTable('episode_comments');
......
......@@ -5,40 +5,39 @@ declare(strict_types=1);
/**
* Class AddLikes Creates likes table in database
*
* @copyright 2021 Podlibre
* @copyright 2021 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
class AddLikes extends Migration
class AddLikes extends BaseMigration
{
#[Override]
public function up(): void
{
$this->forge->addField([
'actor_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'comment_id' => [
'type' => 'BINARY',
'type' => 'BINARY',
'constraint' => 16,
],
]);
$fediverseTablesPrefix = config('Fediverse')
->tablesPrefix;
$this->forge->addField('`created_at` timestamp NOT NULL DEFAULT current_timestamp()');
$this->forge->addPrimaryKey(['actor_id', 'comment_id']);
$this->forge->addForeignKey('actor_id', $fediverseTablesPrefix . 'actors', 'id', '', 'CASCADE');
$this->forge->addForeignKey('actor_id', 'fediverse_actors', 'id', '', 'CASCADE');
$this->forge->addForeignKey('comment_id', 'episode_comments', 'id', '', 'CASCADE');
$this->forge->createTable('likes');
}
#[Override]
public function down(): void
{
$this->forge->dropTable('likes');
......
......@@ -5,33 +5,34 @@ declare(strict_types=1);
/**
* Class AddPages Creates pages table in database
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
class AddPages extends Migration
class AddPages extends BaseMigration
{
#[Override]
public function up(): void
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'unsigned' => true,
'type' => 'INT',
'unsigned' => true,
'auto_increment' => true,
],
'title' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 255,
],
'slug' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 128,
'unique' => true,
'unique' => true,
],
'content_markdown' => [
'type' => 'TEXT',
......@@ -45,15 +46,12 @@ class AddPages extends Migration
'updated_at' => [
'type' => 'DATETIME',
],
'deleted_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addPrimaryKey('id');
$this->forge->createTable('pages');
}
#[Override]
public function down(): void
{
$this->forge->dropTable('pages');
......
......@@ -5,26 +5,27 @@ declare(strict_types=1);
/**
* Class AddPodcastsCategories Creates podcasts_categories table in database
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
class AddPodcastsCategories extends Migration
class AddPodcastsCategories extends BaseMigration
{
#[Override]
public function up(): void
{
$this->forge->addField([
'podcast_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'category_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
]);
......@@ -34,6 +35,7 @@ class AddPodcastsCategories extends Migration
$this->forge->createTable('podcasts_categories');
}
#[Override]
public function down(): void
{
$this->forge->dropTable('podcasts_categories');
......
......@@ -3,72 +3,73 @@
declare(strict_types=1);
/**
* @copyright 2021 Podlibre
* @copyright 2021 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
class AddClips extends Migration
class AddClips extends BaseMigration
{
#[Override]
public function up(): void
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'unsigned' => true,
'type' => 'INT',
'unsigned' => true,
'auto_increment' => true,
],
'podcast_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'episode_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'start_time' => [
'type' => 'DECIMAL(8,3)',
'type' => 'DECIMAL(8,3)',
'unsigned' => true,
],
'duration' => [
// clip duration cannot be higher than 9999,999 seconds ~ 2.77 hours
'type' => 'DECIMAL(7,3)',
'type' => 'DECIMAL(7,3)',
'unsigned' => true,
],
'title' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 128,
],
'type' => [
'type' => 'ENUM',
'type' => 'ENUM',
'constraint' => ['audio', 'video'],
],
'media_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
'null' => true,
'null' => true,
],
'metadata' => [
'type' => 'JSON',
'null' => true,
],
'status' => [
'type' => 'ENUM',
'type' => 'ENUM',
'constraint' => ['queued', 'pending', 'running', 'passed', 'failed'],
],
'logs' => [
'type' => 'TEXT',
],
'created_by' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'updated_by' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'job_started_at' => [
......@@ -96,6 +97,7 @@ class AddClips extends Migration
$this->forge->createTable('clips');
}
#[Override]
public function down(): void
{
$this->forge->dropTable('clips');
......
......@@ -5,54 +5,54 @@ declare(strict_types=1);
/**
* Class Persons Creates persons table in database
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
class AddPersons extends Migration
class AddPersons extends BaseMigration
{
#[Override]
public function up(): void
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'unsigned' => true,
'type' => 'INT',
'unsigned' => true,
'auto_increment' => true,
],
'full_name' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 192,
'comment' => 'This is the full name or alias of the person.',
'comment' => 'This is the full name or alias of the person.',
],
'unique_name' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 192,
'comment' => 'This is the slug name or alias of the person.',
'unique' => true,
'comment' => 'This is the slug name or alias of the person.',
'unique' => true,
],
'information_url' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 512,
'comment' =>
'The url to a relevant resource of information about the person, such as a homepage or third-party profile platform.',
'null' => true,
'comment' => 'The url to a relevant resource of information about the person, such as a homepage or third-party profile platform.',
'null' => true,
],
'avatar_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
'null' => true,
'null' => true,
],
'created_by' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'updated_by' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'created_at' => [
......@@ -70,6 +70,7 @@ class AddPersons extends Migration
$this->forge->createTable('persons');
}
#[Override]
public function down(): void
{
$this->forge->dropTable('persons');
......
......@@ -5,39 +5,40 @@ declare(strict_types=1);
/**
* Class AddPodcastsPersons Creates podcasts_persons table in database
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
class AddPodcastsPersons extends Migration
class AddPodcastsPersons extends BaseMigration
{
#[Override]
public function up(): void
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'unsigned' => true,
'type' => 'INT',
'unsigned' => true,
'auto_increment' => true,
],
'podcast_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'person_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'person_group' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 32,
],
'person_role' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 32,
],
]);
......@@ -48,6 +49,7 @@ class AddPodcastsPersons extends Migration
$this->forge->createTable('podcasts_persons');
}
#[Override]
public function down(): void
{
$this->forge->dropTable('podcasts_persons');
......
......@@ -5,43 +5,44 @@ declare(strict_types=1);
/**
* Class AddEpisodesPersons Creates episodes_persons table in database
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
class AddEpisodesPersons extends Migration
class AddEpisodesPersons extends BaseMigration
{
#[Override]
public function up(): void
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'unsigned' => true,
'type' => 'INT',
'unsigned' => true,
'auto_increment' => true,
],
'podcast_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'episode_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'person_id' => [
'type' => 'INT',
'type' => 'INT',
'unsigned' => true,
],
'person_group' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 32,
],
'person_role' => [
'type' => 'VARCHAR',
'type' => 'VARCHAR',
'constraint' => 32,
],
]);
......@@ -53,6 +54,7 @@ class AddEpisodesPersons extends Migration
$this->forge->createTable('episodes_persons');
}
#[Override]
public function down(): void
{
$this->forge->dropTable('episodes_persons');
......
......@@ -3,19 +3,18 @@
declare(strict_types=1);
/**
* Class AddCreditView Creates Credit View in database
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
class AddCreditView extends Migration
class AddCreditsView extends BaseMigration
{
#[Override]
public function up(): void
{
// Creates View for credit UNION query
......@@ -24,7 +23,7 @@ class AddCreditView extends Migration
$podcastPersonsTable = $this->db->prefixTable('podcasts_persons');
$episodePersonsTable = $this->db->prefixTable('episodes_persons');
$episodesTable = $this->db->prefixTable('episodes');
$createQuery = <<<CODE_SAMPLE
$createQuery = <<<SQL
CREATE VIEW `{$viewName}` AS
SELECT `person_group`, `person_id`, `full_name`, `person_role`, `podcast_id`, NULL AS `episode_id` FROM `{$podcastPersonsTable}`
INNER JOIN `{$personsTable}`
......@@ -35,12 +34,13 @@ class AddCreditView extends Migration
ON (`person_id`=`{$personsTable}`.`id`)
INNER JOIN `{$episodesTable}`
ON (`episode_id`=`{$episodesTable}`.`id`)
WHERE `{$episodesTable}`.published_at <= NOW()
WHERE `{$episodesTable}`.published_at <= UTC_TIMESTAMP()
ORDER BY `person_group`, `full_name`, `person_role`, `podcast_id`, `episode_id`;
CODE_SAMPLE;
SQL;
$this->db->query($createQuery);
}
#[Override]
public function down(): void
{
$viewName = $this->db->prefixTable('credits');
......
......@@ -5,40 +5,48 @@ declare(strict_types=1);
/**
* Class AddEpisodeIdToPosts Adds episode_id field to posts table in database
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
class AddEpisodeIdToPosts extends Migration
class AddEpisodeIdToPosts extends BaseMigration
{
#[Override]
public function up(): void
{
$prefix = $this->db->getPrefix();
$fediverseTablesPrefix = config('Fediverse')
->tablesPrefix;
$createQuery = <<<CODE_SAMPLE
ALTER TABLE {$prefix}{$fediverseTablesPrefix}posts
ADD COLUMN `episode_id` INT UNSIGNED NULL AFTER `replies_count`,
ADD FOREIGN KEY {$prefix}{$fediverseTablesPrefix}posts_episode_id_foreign(episode_id) REFERENCES {$prefix}episodes(id) ON DELETE CASCADE;
CODE_SAMPLE;
$this->db->query($createQuery);
$this->forge->addColumn('fediverse_posts', [
'episode_id' => [
'type' => 'INT',
'unsigned' => true,
'null' => true,
'after' => 'replies_count',
],
]);
$this->forge->addForeignKey(
'episode_id',
'episodes',
'id',
'',
'CASCADE',
$prefix . 'fediverse_posts_episode_id_foreign',
);
$this->forge->processIndexes('fediverse_posts');
}
#[Override]
public function down(): void
{
$fediverseTablesPrefix = config('Fediverse')
->tablesPrefix;
$prefix = $this->db->getPrefix();
$this->forge->dropForeignKey(
$fediverseTablesPrefix . 'posts',
$fediverseTablesPrefix . 'posts_episode_id_foreign'
);
$this->forge->dropColumn($fediverseTablesPrefix . 'posts', 'episode_id');
$this->forge->dropForeignKey('fediverse_posts', $prefix . 'fediverse_posts_episode_id_foreign');
$this->forge->dropColumn('fediverse_posts', 'episode_id');
}
}
......@@ -5,40 +5,48 @@ declare(strict_types=1);
/**
* Class AddCreatedByToPosts Adds created_by field to posts table in database
*
* @copyright 2020 Podlibre
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Override;
class AddCreatedByToPosts extends Migration
class AddCreatedByToPosts extends BaseMigration
{
#[Override]
public function up(): void
{
$prefix = $this->db->getPrefix();
$fediverseTablesPrefix = config('Fediverse')
->tablesPrefix;
$createQuery = <<<CODE_SAMPLE
ALTER TABLE {$prefix}{$fediverseTablesPrefix}posts
ADD COLUMN `created_by` INT UNSIGNED AFTER `episode_id`,
ADD FOREIGN KEY {$prefix}{$fediverseTablesPrefix}posts_created_by_foreign(created_by) REFERENCES {$prefix}users(id) ON DELETE CASCADE;
CODE_SAMPLE;
$this->db->query($createQuery);
$this->forge->addColumn('fediverse_posts', [
'created_by' => [
'type' => 'INT',
'unsigned' => true,
'null' => true,
'after' => 'episode_id',
],
]);
$this->forge->addForeignKey(
'created_by',
'users',
'id',
'',
'CASCADE',
$prefix . 'fediverse_posts_created_by_foreign',
);
$this->forge->processIndexes('fediverse_posts');
}
#[Override]
public function down(): void
{
$fediverseTablesPrefix = config('Fediverse')
->tablesPrefix;
$prefix = $this->db->getPrefix();
$this->forge->dropForeignKey(
$fediverseTablesPrefix . 'posts',
$fediverseTablesPrefix . 'posts_created_by_foreign'
);
$this->forge->dropColumn($fediverseTablesPrefix . 'posts', 'created_by');
$this->forge->dropForeignKey('fediverse_posts', $prefix . 'fediverse_posts_created_by_foreign');
$this->forge->dropColumn('fediverse_posts', 'created_by');
}
}
<?php
declare(strict_types=1);
namespace App\Database\Migrations;
use Override;
class AddFullTextSearchIndexes extends BaseMigration
{
#[Override]
public function up(): void
{
$prefix = $this->db->getPrefix();
$createQuery = <<<SQL
ALTER TABLE {$prefix}episodes DROP INDEX title;
SQL;
$this->db->query($createQuery);
$createQuery = <<<SQL
ALTER TABLE {$prefix}episodes
ADD FULLTEXT episodes_search (title, description_markdown, slug, location_name);
SQL;
$this->db->query($createQuery);
$createQuery = <<<SQL
ALTER TABLE {$prefix}podcasts
ADD FULLTEXT podcasts_search (title, description_markdown, handle, location_name);
SQL;
$this->db->query($createQuery);
}
#[Override]
public function down(): void
{
$prefix = $this->db->getPrefix();
$createQuery = <<<SQL
ALTER TABLE {$prefix}episodes
DROP INDEX episodes_search;
SQL;
$this->db->query($createQuery);
$createQuery = <<<SQL
ALTER TABLE {$prefix}podcasts
DROP INDEX podcasts_search;
SQL;
$this->db->query($createQuery);
}
}
<?php
declare(strict_types=1);
namespace App\Database\Migrations;
use Override;
class AddEpisodePreviewId extends BaseMigration
{
#[Override]
public function up(): void
{
$fields = [
'preview_id' => [
'type' => 'BINARY',
'constraint' => 16,
'after' => 'podcast_id',
],
];
$this->forge->addColumn('episodes', $fields);
// set preview_id as unique key
$prefix = $this->db->getPrefix();
$uniquePreviewId = <<<CODE_SAMPLE
ALTER TABLE `{$prefix}episodes`
ADD CONSTRAINT `preview_id` UNIQUE (`preview_id`);
CODE_SAMPLE;
$this->db->query($uniquePreviewId);
}
#[Override]
public function down(): void
{
$fields = ['preview_id'];
$this->forge->dropColumn('episodes', $fields);
}
}
<?php
declare(strict_types=1);
/**
* Class AddPodcastsOwnerEmailRemovedFromFeed adds is_owner_email_removed_from_feed field to podcast table in database
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use Override;
class AddPodcastsOwnerEmailRemovedFromFeed extends BaseMigration
{
#[Override]
public function up(): void
{
$fields = [
'is_owner_email_removed_from_feed' => [
'type' => 'BOOLEAN',
'null' => false,
'default' => 0,
'after' => 'owner_email',
],
];
$this->forge->addColumn('podcasts', $fields);
}
#[Override]
public function down(): void
{
$fields = ['is_owner_email_removed_from_feed'];
$this->forge->dropColumn('podcasts', $fields);
}
}
<?php
declare(strict_types=1);
/**
* Class AddPodcastsMediumField adds medium field to podcast table in database
*
* @copyright 2020 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use Override;
class AddPodcastsMediumField extends BaseMigration
{
#[Override]
public function up(): void
{
$fields = [
'medium' => [
'type' => "ENUM('podcast','music','audiobook')",
'null' => false,
'default' => 'podcast',
'after' => 'type',
],
];
$this->forge->addColumn('podcasts', $fields);
}
#[Override]
public function down(): void
{
$fields = ['medium'];
$this->forge->dropColumn('podcasts', $fields);
}
}
<?php
declare(strict_types=1);
/**
* Class AddPodcastsVerifyTxtField adds 1 field to podcast table in database to support podcast:txt tag
*
* @copyright 2024 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Database\Migrations;
use Override;
class AddPodcastsVerifyTxtField extends BaseMigration
{
#[Override]
public function up(): void
{
$fields = [
'verify_txt' => [
'type' => 'TEXT',
'null' => true,
'after' => 'location_osm',
],
];
$this->forge->addColumn('podcasts', $fields);
}
#[Override]
public function down(): void
{
$this->forge->dropColumn('podcasts', 'verify_txt');
}
}