2020-12-07 20:13:46 +00:00
|
|
|
<?php
|
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-12-07 20:13:46 +00:00
|
|
|
/**
|
2022-02-19 16:06:11 +00:00
|
|
|
* @copyright 2021 Ad Aures
|
2020-12-07 20:13:46 +00:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
|
2024-05-29 10:24:13 +00:00
|
|
|
use Override;
|
|
|
|
|
2023-06-13 16:05:02 +00:00
|
|
|
class AddClips extends BaseMigration
|
2020-12-07 20:13:46 +00:00
|
|
|
{
|
2024-05-29 10:24:13 +00:00
|
|
|
#[Override]
|
2021-05-06 14:00:48 +00:00
|
|
|
public function up(): void
|
2020-12-07 20:13:46 +00:00
|
|
|
{
|
|
|
|
$this->forge->addField([
|
|
|
|
'id' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2020-12-07 20:13:46 +00:00
|
|
|
'auto_increment' => true,
|
|
|
|
],
|
|
|
|
'podcast_id' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'INT',
|
2020-12-07 20:13:46 +00:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'episode_id' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'INT',
|
2020-12-07 20:13:46 +00:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'start_time' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'DECIMAL(8,3)',
|
2021-06-11 13:01:42 +00:00
|
|
|
'unsigned' => true,
|
2020-12-07 20:13:46 +00:00
|
|
|
],
|
|
|
|
'duration' => [
|
2021-12-14 16:41:10 +00:00
|
|
|
// clip duration cannot be higher than 9999,999 seconds ~ 2.77 hours
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'DECIMAL(7,3)',
|
2021-06-11 13:01:42 +00:00
|
|
|
'unsigned' => true,
|
2020-12-07 20:13:46 +00:00
|
|
|
],
|
2022-01-03 13:52:07 +00:00
|
|
|
'title' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'VARCHAR',
|
2020-12-07 20:13:46 +00:00
|
|
|
'constraint' => 128,
|
|
|
|
],
|
2021-12-14 16:41:10 +00:00
|
|
|
'type' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'ENUM',
|
2021-12-14 16:41:10 +00:00
|
|
|
'constraint' => ['audio', 'video'],
|
|
|
|
],
|
|
|
|
'media_id' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'INT',
|
2021-12-14 16:41:10 +00:00
|
|
|
'unsigned' => true,
|
2023-06-12 14:47:38 +00:00
|
|
|
'null' => true,
|
2021-12-21 16:25:03 +00:00
|
|
|
],
|
|
|
|
'metadata' => [
|
|
|
|
'type' => 'JSON',
|
|
|
|
'null' => true,
|
2021-12-14 16:41:10 +00:00
|
|
|
],
|
|
|
|
'status' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'ENUM',
|
2021-12-21 16:25:03 +00:00
|
|
|
'constraint' => ['queued', 'pending', 'running', 'passed', 'failed'],
|
2021-12-14 16:41:10 +00:00
|
|
|
],
|
|
|
|
'logs' => [
|
|
|
|
'type' => 'TEXT',
|
|
|
|
],
|
2020-12-07 20:13:46 +00:00
|
|
|
'created_by' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'INT',
|
2020-12-07 20:13:46 +00:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
|
|
|
'updated_by' => [
|
2023-06-12 14:47:38 +00:00
|
|
|
'type' => 'INT',
|
2020-12-07 20:13:46 +00:00
|
|
|
'unsigned' => true,
|
|
|
|
],
|
2021-12-24 17:55:56 +00:00
|
|
|
'job_started_at' => [
|
2020-12-07 20:13:46 +00:00
|
|
|
'type' => 'DATETIME',
|
2021-12-24 17:55:56 +00:00
|
|
|
'null' => true,
|
2020-12-07 20:13:46 +00:00
|
|
|
],
|
2021-12-24 17:55:56 +00:00
|
|
|
'job_ended_at' => [
|
2020-12-07 20:13:46 +00:00
|
|
|
'type' => 'DATETIME',
|
2021-12-24 17:55:56 +00:00
|
|
|
'null' => true,
|
2020-12-07 20:13:46 +00:00
|
|
|
],
|
2021-12-24 17:55:56 +00:00
|
|
|
'created_at' => [
|
|
|
|
'type' => 'DATETIME',
|
|
|
|
],
|
|
|
|
'updated_at' => [
|
2020-12-07 20:13:46 +00:00
|
|
|
'type' => 'DATETIME',
|
|
|
|
],
|
|
|
|
]);
|
2021-12-14 16:41:10 +00:00
|
|
|
|
2020-12-07 20:13:46 +00:00
|
|
|
$this->forge->addKey('id', true);
|
2021-06-08 09:52:11 +00:00
|
|
|
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id', '', 'CASCADE');
|
|
|
|
$this->forge->addForeignKey('episode_id', 'episodes', 'id', '', 'CASCADE');
|
2021-12-14 16:41:10 +00:00
|
|
|
$this->forge->addForeignKey('media_id', 'media', 'id', '', 'CASCADE');
|
2020-12-07 20:13:46 +00:00
|
|
|
$this->forge->addForeignKey('created_by', 'users', 'id');
|
|
|
|
$this->forge->addForeignKey('updated_by', 'users', 'id');
|
2021-12-14 16:41:10 +00:00
|
|
|
$this->forge->createTable('clips');
|
2020-12-07 20:13:46 +00:00
|
|
|
}
|
|
|
|
|
2024-05-29 10:24:13 +00:00
|
|
|
#[Override]
|
2021-05-06 14:00:48 +00:00
|
|
|
public function down(): void
|
2020-12-07 20:13:46 +00:00
|
|
|
{
|
2021-12-14 16:41:10 +00:00
|
|
|
$this->forge->dropTable('clips');
|
2020-12-07 20:13:46 +00:00
|
|
|
}
|
|
|
|
}
|