2020-05-29 18:25:17 +02:00
|
|
|
<?php
|
2020-08-04 13:25:22 +02:00
|
|
|
|
2021-06-08 11:52:11 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-06-10 17:00:12 +02:00
|
|
|
/**
|
2021-05-19 18:35:13 +02:00
|
|
|
* Class AddCategories Creates categories table in database
|
2020-06-10 17:00:12 +02:00
|
|
|
*
|
2022-02-19 17:06:11 +01:00
|
|
|
* @copyright 2020 Ad Aures
|
2020-06-10 17:00:12 +02:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
2020-05-29 18:25:17 +02:00
|
|
|
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
|
2020-06-10 17:00:12 +02:00
|
|
|
use CodeIgniter\Database\Migration;
|
2020-05-29 18:25:17 +02:00
|
|
|
|
|
|
|
class AddCategories extends Migration
|
|
|
|
{
|
2021-05-06 16:00:48 +02:00
|
|
|
public function up(): void
|
2020-05-29 18:25:17 +02:00
|
|
|
{
|
|
|
|
$this->forge->addField([
|
2020-05-31 21:15:52 +02:00
|
|
|
'id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2020-05-29 18:25:17 +02:00
|
|
|
],
|
2020-05-31 21:15:52 +02:00
|
|
|
'parent_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2021-05-25 16:05:12 +02:00
|
|
|
'null' => true,
|
2020-05-29 18:25:17 +02:00
|
|
|
],
|
2020-05-31 21:15:52 +02:00
|
|
|
'code' => [
|
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 16:45:19 +01:00
|
|
|
'constraint' => 32,
|
2020-05-31 21:15:52 +02:00
|
|
|
],
|
|
|
|
'apple_category' => [
|
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 16:45:19 +01:00
|
|
|
'constraint' => 32,
|
2020-05-29 18:25:17 +02:00
|
|
|
],
|
|
|
|
'google_category' => [
|
2020-05-31 21:15:52 +02:00
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 16:45:19 +01:00
|
|
|
'constraint' => 32,
|
2020-05-29 18:25:17 +02:00
|
|
|
],
|
|
|
|
]);
|
2021-04-02 19:20:02 +02:00
|
|
|
$this->forge->addPrimaryKey('id');
|
2020-06-26 16:34:52 +02:00
|
|
|
$this->forge->addUniqueKey('code');
|
2020-05-29 18:25:17 +02:00
|
|
|
$this->forge->addForeignKey('parent_id', 'categories', 'id');
|
|
|
|
$this->forge->createTable('categories');
|
|
|
|
}
|
|
|
|
|
2021-05-06 16:00:48 +02:00
|
|
|
public function down(): void
|
2020-05-29 18:25:17 +02:00
|
|
|
{
|
|
|
|
$this->forge->dropTable('categories');
|
|
|
|
}
|
|
|
|
}
|